Why a PNG turns black when you convert it to JPG
By the Imizer team · Published
Short answer
JPG cannot store transparency, so every transparent pixel has to become a solid colour during conversion. Many converters drop the transparency and keep whatever colour sits underneath it, and in a browser canvas that colour is black. The fix is to fill the background with white, or any colour you choose, before the JPG is written. Our PNG to JPG converter does that for you.
What a transparent pixel actually contains
Every pixel in a PNG with transparency has four numbers: red, green, blue and alpha. Alpha runs from 0, fully transparent, to 255, fully opaque. The part people miss is that a fully transparent pixel still has red, green and blue values. They are invisible while alpha is 0, so nobody notices what they are, and most software sets them to zero. Zero, zero, zero is black.
JPG has three channels and no alpha. When a PNG is converted, the alpha number has nowhere to go. If the converter simply throws it away, the colour values that were hiding behind it become visible, and a logo that sat on nothing now sits on a black rectangle.
Browsers make this close to certain. A canvas, which is what most online converters use to do the work, stores pixels with their colour already multiplied by their alpha. A transparent pixel is stored as transparent black no matter what the original file held. Ask that canvas for a JPG and the black is what comes out.
Why some converters give white and others give black
The difference is one step. A converter that gets this right paints a solid background first, usually white, and then draws the image over it. Transparent areas let the white show through, half-transparent areas blend with it, and only then is the JPG written. A converter that skips the step hands the encoder the raw pixels, and the encoder does the only thing it can, which is ignore the alpha.
You cannot tell which kind a tool is from its page. You find out by converting something with a transparent background and looking at the result. Until October 2026 our own converter was the black kind; it now fills with white before encoding, and the WebP to JPG converter does the same.
The dark fringe around edges
Sometimes the background comes out white but the outline of the logo has a grubby dark edge, as if it had been traced with a soft pencil. That is the same problem in a smaller place. Smooth edges are drawn with partly transparent pixels, which blend the shape into whatever is behind it. If those pixels lose their alpha instead of being blended against the new background, they keep their darkened, premultiplied colour, and a one or two pixel dark ring appears.
Filling the background before encoding fixes the fringe as well, because the edge pixels are blended against white at full precision rather than having their alpha discarded. If you are cleaning up a file by hand, this is also why erasing the black afterwards never quite works: the dark tint is baked into the edge pixels themselves.
Three ways to fix it
Pick whichever matches the tools you already have. All three do the same thing underneath: composite onto a solid colour, then encode.
- Use a converter that flattens for you. Our PNG to JPG converter fills transparency with white and runs in your browser, so the file is never uploaded. Up to five images at a time.
- Flatten in an image editor before exporting. In Photoshop, add a new layer filled with white and move it to the bottom. In GIMP, set the background colour to white and use Image, then Flatten Image, which fills transparency with that colour.
- Do it from the command line. ImageMagick and Python’s Pillow library both need the background stated explicitly; the samples below show how.
magick input.png -background white -flatten output.jpg
# Python, with Pillow
from PIL import Image
src = Image.open("input.png").convert("RGBA")
bg = Image.new("RGB", src.size, (255, 255, 255))
bg.paste(src, mask=src.getchannel("A"))
bg.save("output.jpg", quality=85)Pick the background colour on purpose
White is right most of the time: marketplace listings usually ask for it, documents are printed on it, and most web pages are close to it. It is wrong when the image will sit on a coloured or dark page, where a white box around a logo looks like a mistake. In that case either flatten onto the colour of the page, or keep the transparency and do not use JPG at all.
If the subject is a photo whose background you want gone and replaced, rather than a graphic that already has transparency, that is a different job. The change background color tool finds the subject with an on-device AI model and composites it onto any colour you pick, which gives cleaner edges than cutting out first and flattening afterwards.
When not to convert to JPG
JPG is the format for photographs that have to open anywhere. It is a poor choice for logos, screenshots and anything with text, because its compression smears sharp edges into a faint ripple, and it can never be transparent. If the image is going on a website, WebP keeps the transparency and is usually smaller than the JPG would have been. If you need an exact copy for editing, keep the PNG, or use the JPG to PNG converter to go the other way.
The one case where JPG is non-negotiable is an upload form or an old piece of software that accepts nothing else. Then flatten onto the colour you want, convert, and check the result before you send it.