A logo saved as a JPEG with a white box around it looks wrong on any colored background, dark website header, or product mockup. The fix is a transparent PNG. If you do not have the original vector file, there are two reliable ways to get one.

First, check for a vector file

If an SVG, AI, EPS, or PDF version of the logo exists, use it. Vector logos have no background to remove and scale to any size. The methods below are for when you only have a raster image like JPG or PNG.

Method 1: AI background removal

An AI background removal API finds the logo as the subject and removes everything around it. This works well for logos that are photos, mascots, badges, or anything with gradients, shadows, or many colors.

curl -X POST https://fapihub.com/v2/rembg/ \
  -H "ApiKey: YOUR_API_KEY" \
  -F "image=@logo.jpg" \
  --output logo-transparent.png

Watch for: white areas inside the logo. AI segmentation treats the logo as one object, so enclosed white spaces (inside an "O", or a white icon on a colored shape) may stay white rather than becoming transparent. That is often what you want for a badge, but not for lettering.

The same request in Python

Logos vary a lot, from flat wordmarks to illustrated mascots, so the optional model parameter is worth testing here. Try each model on your logo and keep the one that looks best.

import requests

with open("logo.jpg", "rb") as image_file:
    response = requests.post(
        "https://fapihub.com/v2/rembg/",
        headers={"ApiKey": "YOUR_API_KEY"},
        files={"image": image_file},
        data={"model": "falcon"},  # also try "aurora" and "ghost"
        timeout=60,
    )
response.raise_for_status()

with open("logo-transparent.png", "wb") as out:
    out.write(response.content)

See the Python background removal guide for retries and batch helpers.

Method 2: Color-keying white pixels

For flat logos (text and simple shapes on pure white), you can make every near-white pixel transparent. This also clears the holes inside letters. With Pillow:

from PIL import Image

THRESHOLD = 240  # pixels brighter than this become transparent

logo = Image.open("logo.jpg").convert("RGBA")
pixels = [
    (r, g, b, 0) if min(r, g, b) >= THRESHOLD else (r, g, b, a)
    for r, g, b, a in logo.getdata()
]
logo.putdata(pixels)
logo.save("logo-transparent.png")

Watch for: white parts that belong to the logo will also disappear, and JPEG compression leaves light gray fringes around edges. Lower the threshold if too much is removed, and raise it if a halo remains.

Which method to use

Logo typeBest method
Wordmark or simple shapes on pure whiteColor-keying
Logo with white elements that must stayAI background removal
Photo, mascot, gradients, or shadowsAI background removal
Logo photographed on paper, a sign, or a shirtAI background removal
Logo on a busy or non-white backgroundAI background removal

Getting clean edges

  • Start large. Upscale tiny logos before processing. Edges look smoother when the source has more pixels.
  • Test on dark. Place the result on a black background. Light halos are invisible on white but obvious on dark headers.
  • Save as PNG or WebP. JPEG does not support transparency and will put a background back.
  • Crop the padding. Trim empty transparent space so the logo aligns properly in layouts.

Doing it for many logos

Agencies, marketplaces, and directory sites often need to clean up hundreds of partner or customer logos. Our bulk background removal guide includes a script you can point at a folder. Try a single logo first in the playground, and see our quality tips for difficult edges.

Method 3: Combine both

Some logos need both approaches: AI removal to handle a shadow, texture, or photographed background, and color-keying to clear enclosed white spaces in the lettering. Run the AI removal first, then key out near-white pixels that remain inside the result.

from PIL import Image

THRESHOLD = 235

logo = Image.open("logo-transparent.png").convert("RGBA")  # output of /v2/rembg/
logo.putdata([
    (r, g, b, 0) if a > 0 and min(r, g, b) >= THRESHOLD else (r, g, b, a)
    for r, g, b, a in logo.getdata()
])
logo.save("logo-clean.png")

Only use this when the logo has no white elements that should stay. If it does, mask those areas out before keying, or accept that the enclosed spaces stay white.

Softer edges than a hard threshold

The threshold in Method 2 is all or nothing, which can leave jagged or fringed edges on anti-aliased text. For a dark logo on white, a smoother option is to derive transparency from how far each pixel is from white. Pure white becomes fully transparent, the logo color stays fully opaque, and the soft pixels in between become partly transparent instead of light gray.

from PIL import Image, ImageChops, ImageOps

logo = Image.open("logo.jpg").convert("RGB")
r, g, b = logo.split()

darkest = ImageChops.darker(ImageChops.darker(r, g), b)  # per-pixel min channel
alpha = ImageOps.invert(darkest)                          # white -> 0, dark -> high
alpha = alpha.point(lambda v: min(255, v * 2))            # push the logo body to fully opaque

result = logo.convert("RGBA")
result.putalpha(alpha)
result.save("logo-soft.png")

This works best for dark or saturated logos. Light colors such as pale yellow are close to white, so they become partly transparent too. Raise the multiplier or switch to AI removal for those.

The ImageMagick shortcut

If you prefer the command line, ImageMagick can color-key and trim in one go. The -fuzz percentage plays the same role as the threshold above.

magick logo.jpg -fuzz 8% -transparent white -trim +repage logo-transparent.png

Trim and export the sizes you need

Once the background is transparent, crop to the visible pixels, add a consistent margin, and export the sizes your site or app uses. Working from one clean master keeps every size aligned.

from PIL import Image

master = Image.open("logo-clean.png").convert("RGBA")
master = master.crop(master.getchannel("A").getbbox())

margin = round(max(master.size) * 0.05)
padded = Image.new("RGBA", (master.width + 2 * margin, master.height + 2 * margin), (0, 0, 0, 0))
padded.paste(master, (margin, margin), master)

for height in (512, 256, 128, 64):
    width = round(padded.width * height / padded.height)
    resized = padded.resize((width, height), Image.LANCZOS)
    resized.save(f"logo-{height}.png")
    resized.save(f"logo-{height}.webp", lossless=True)

Downscaling from a large master gives cleaner small sizes than upscaling a small file. For favicons and app icons, also check the result at its real display size, because thin strokes can disappear.

Final checklist

  1. Use the vector file if one exists.
  2. Pick a method based on the logo type table above.
  3. Preview the result on white, black, and your brand's main background color.
  4. Check enclosed spaces in letters such as O, A, and B.
  5. Trim padding and add a consistent margin.
  6. Save as PNG or WebP, never JPEG.

What it costs for a logo library

Color-keying runs locally and costs nothing. The AI method uses one request per logo. A directory site cleaning up 400 partner logos would need 400 requests, which is $10 for 1,000 requests on the Per Usage plan with the remainder kept for later because those requests never expire, or a single month of Pro at $15 for 7,500 requests. A handful of logos fits in the free Basic plan's 100 monthly requests. If a request returns 400 invalid_image, one common cause is a file format the API does not accept: convert SVG, AI, EPS, or PDF files to PNG first, or better, just use the vector. Accepted formats are JPEG, PNG, WebP, BMP, and GIF, up to 10 MB. Plan details are on the pricing section.

Frequently asked questions

Why is there still a white box around my logo after saving?

The file was probably saved as JPEG, which does not support transparency. Save as PNG or WebP. Also check that the viewer you are using shows transparency, since some display a white background behind transparent images.

Why did the inside of the letters stay white?

AI segmentation treats the logo as one object, so enclosed white areas are often kept. Use color-keying for flat logos, or the combined method above to clear them after AI removal.

Can I upload an SVG to remove its background?

No. The API accepts JPEG, PNG, WebP, BMP, and GIF. An SVG usually has no background to remove anyway; if it does, delete the background shape in a vector editor.

How do I get rid of a light halo around the edges?

With color-keying, adjust the threshold or switch to the soft-edge method. With AI removal, start from a larger source image. In both cases, preview on a dark background, where halos are easiest to see.