Skip to content
KBExactKB

Guides·November 24, 2026

Why Transparent PNGs Turn Black When Converted to JPG (and How to Keep a White Background)

You export a logo or a signature as PNG because the background is transparent. A portal wants JPG under 50KB. You convert, and the download is a black rectangle with a ghost of your drawing. This is not a mysterious encoder bug. It is how pixels work.

JPEG cannot store “no pixel”

PNG uses RGBA. The A channel is opacity. JPEG stores YCbCr color only. When software “flattens” a PNG, every transparent pixel still needs an RGB value. If the converter does nothing, many canvases — including the HTML Canvas default — use (0, 0, 0, 0). Zero alpha, but also zero red, green, and blue. Drop the alpha, and you have black.

MozJPEG, like libjpeg, does not invent a background. It encodes the RGB it is given. Transparent signatures become tar.

The one-line fix

Before drawing the PNG onto a canvas:

fillStyle = #FFFFFF
fillRect(0, 0, width, height)
drawImage(png)
encode JPEG

White (or the page color the form asked for) is now the RGB of former transparent pixels. ExactKB does this in the image worker and in the PDF page renderer. It is also why iOS memory cleanup (canvas.width = 0) happens after encode, not before the fill.

When white is the wrong pad

A dark-mode screenshot with transparent corners should probably be padded with the screenshot’s own background, not white. V1 always uses white because visa, exam, and KYC forms specify white or off-white. If you are compressing UI screenshots for a bug report, flatten in your design tool first.

PNG is the wrong vehicle for 50KB photos

A photographic PNG is enormous. Portals that say 50KB mean JPEG. Convert, with a white matte, then let a quality binary search plus optional 25% downscales hit the cap. That is Resize image under 50KB. Logos that must stay sharp at 10KB should remain small PNG or SVG if the portal allows it — JPEG will ring around type.

How to check you won

Open the JPG on a dark desktop wallpaper. If you see a white page, the matte worked. If you see black, the converter skipped the fill. If you see checkerboard, you are still looking at a PNG.

Try it in your browser:compress a PDF,merge photos, orhit a 50KB image cap.