Converting a PNG to a JPG does not start with the quality slider. It starts with 13 bytes at the top of the PNG file, and those bytes decide what kind of JPG you get. I saved one 2400 × 1600 photograph six different ways and converted all six at the same setting.
The file you get back is shaped by the PNG you brought in. Colour type 0 and colour type 2 produce different component counts, and the two JPGs decoded to byte-identical pixels while differing by 19,362 bytes — 6.70%. Full chroma on a grayscale source cost 13.28% more bytes and changed 0 of 3,840,000 pixels. A palette PNG 3.28× smaller than the truecolour one came out as a bigger JPG. And in a browser the transparent area flattens to black, not white.
A PNG file starts with an 8-byte signature, then a chunk list. The first chunk is always IHDR, and it is 13 bytes long. Two of the fields inside it decide almost everything downstream: the colour type, which says how many kinds of channel the pixels have, and the bit depth, which says how many bits each channel value gets.
Here is the same photograph saved six ways, and the header each one carries. All six are 2400 × 1600 and none is interlaced.
| PNG saved as | Colour type | Bit depth | Extra chunk | PNG bytes |
|---|---|---|---|---|
| Truecolour | 2 | 8 | — | 3,351,429 |
| Truecolour + alpha | 6 | 8 | — | 3,659,146 |
| Grayscale | 0 | 8 | — | 1,554,802 |
| Grayscale + alpha | 4 | 8 | — | 1,759,517 |
| 16-bit | 0 | 16 | — | 1,759,901 |
| Indexed, 64 colours | 3 | 8 | PLTE | 1,022,911 |
The palette version is the interesting one because it carries a chunk the others do not: PLTE, 192 bytes long — 64 colours at 3 bytes each. It is also the smallest file on the page at 1,022,911 bytes, 3.28× smaller than the truecolour original. Hold on to that number; it comes back with a sign change.
The header does not describe the picture. It describes the storage, and the storage is what the encoder has to honour.
A JPG frame header declares how many colour components it holds and how each one is sampled. The grayscale PNG converts to a JPG with one component — luma, sampled 1×1, with no colour channels at all. Convert the same pixels through the RGB path and you get three components: luma sampled 2×2, and two chroma planes sampled 1×1.
| Grayscale PNG → JPG | Components | Sampling | Bytes |
|---|---|---|---|
| Direct, luma only | 1 | 1×1 | 288,835 |
| Forced through RGB | 3 | 2×2 / 1×1 / 1×1 | 308,197 |
| Difference | +2 | — | +19,362 (+6.70%) |
Here is the part that should stop you. I decoded both output files and compared all 3,840,000 pixels of each. Zero pixels differ. Not "the difference is small" — the two pictures are byte-for-byte the same after decoding. The three-component file is 6.70% larger for a chroma pair that carries no information, because the source had no colour to carry.
Two chroma planes of constant neutral, sampled and coded and entropy-coded across the whole frame, produce 19,362 extra bytes and nothing else. The PLTE in a palette PNG and the 4:2:0 chroma in a JPG are both ways of saying "there is less here than three full channels would suggest" — but a JPG cannot have a palette, so the palette has to be expanded before the JPG is written.
The extra bytes are not error and they are not detail. They are two empty chroma planes.
There is a second switch in the frame header, and it is worth separating from the first. Chroma subsampling says how finely the two colour planes are sampled relative to luma. 4:2:0 halves them; 4:4:4 keeps them full. I asked for full chroma on the same grayscale source.
| Same grayscale source | JPG bytes | Cost | Pixels changed |
|---|---|---|---|
| 4:2:0 chroma | 308,197 | — | — |
| 4:4:4 chroma | 349,130 | +40,933 (+13.28%) | 0 |
| 4:4:4 on the truecolour source | 381,808 | +59,877 (+18.60%) | 1,428,712 |
On grayscale, asking for 4:4:4 bought 40,933 extra bytes and changed not one pixel — the decoded files are identical, 0 differing pixels out of 3,840,000, maximum difference 0. On the truecolour source the same request cost 59,877 bytes and did change the picture: 1,428,712 pixels, 37.2% of the frame. So "full chroma" is not a quality upgrade or a quality tax. It is a switch that either does something or does nothing, and whether it does something depends on whether your PNG had colour in it.
This is why a grayscale PNG should not be treated as "a small PNG". It is a different format wearing the same extension. It gets a different JPG, and the JPG is smaller for a reason that has nothing to do with compression settings.
Back to that palette PNG, the smallest of the six at 1,022,911 bytes. A palette PNG stores each pixel as one index into a small colour table, which is why it compresses so well. A JPG has no palette mode at all — the pixels have to be expanded back to full RGB before the JPEG encoder can touch them, and the 64-colour quantisation is then baked into the picture as a permanent error.
| Same picture | PNG bytes | JPG bytes | Ratio |
|---|---|---|---|
| Truecolour PNG | 3,351,429 | 321,931 | 0.0960× |
| Palette PNG, 64 colours | 1,022,911 | 327,661 | 0.3203× |
| Difference | 3.28× smaller | 5,730 bytes bigger (+1.78%) | — |
The palette PNG is 3.28× smaller than the truecolour PNG, and its JPG is 1.78% bigger. It is also measurably worse: 18.076% of pixels moved by more than 2 levels against 13.218% for the truecolour route, and the worst single pixel moved 57 levels instead of 36. The colour reduction that made the PNG small did not survive the conversion. The quantisation is still there — it has simply been re-encoded as JPEG ringing instead of as a compact index table.
If you want the small file, the small file is the PNG. Converting it to JPG does not recover the size, because the size came from a data structure the JPG cannot have.
Here is where I expected to agree with the other converters, and did not. The widely repeated line is that a transparent PNG converted to JPG gets a white background. I built a PNG with a red disc on a fully transparent ground, put it through a browser canvas, and read the output pixels back.
The answer depends on a detail nobody states: what colour is stored underneath the transparency. I built the same shape three times, storing black, then magenta, then white in the transparent area, and converted all three in a browser canvas.
| Stored under the transparent area | Browser JPG corner | Library route |
|---|---|---|
| Black | 0, 0, 0 | 0, 0, 0 |
| Magenta | 0, 0, 0 | 255, 0, 255 |
| White | 0, 0, 0 | 255, 255, 255 |
The browser gives black every time, whatever was underneath. The library route keeps the stored colour. The browser is not picking a fill colour; it is multiplying the stored colour by the alpha value, and a fully transparent pixel has an alpha of zero, so zero times anything is zero. The PNG specification allows the RGB values under a transparent pixel to be anything at all, which is why the two routes disagree.
I built an 8-step alpha ramp over a magenta ground and measured the formula. For a browser canvas with no background painted, the output is:
JPG = stored RGB × alpha ÷ 255
Across all 8 sample points the predicted values matched the measured ones to within 1 level of 255, which is the rounding floor of the format. With a white rectangle painted on the canvas first, the formula becomes:
JPG = stored RGB × alpha ÷ 255 + 255 × (1 − alpha ÷ 255)
Also verified to within 1 level. The practical consequence: a transparent PNG viewed against a light background looks one thing, and the JPG you get from a browser canvas is measurably darker. On my ramp, the pixel the viewer shows as near-white comes out of the conversion at 0, 0, 0. The gap between what you saw and what you got is up to 255 levels.
Same magenta ground, eight alpha values. The browser multiplies by alpha; the viewer composites against white.
If your PNG has a transparent area and you want a predictable result, paint the background first and convert into that. The measurement above is why: the default is a multiplication, and multiplication takes the light out of every semi-transparent pixel.
The quickest way to "convert" a PNG is to change its name. I tried it, because the claim that this does nothing deserves a measurement rather than an assertion.
I renamed a PNG with a real transparent background to .jpg and served it with the MIME type the new extension implies. The browser loaded it without complaint and rendered it correctly. But the bytes are still the PNG bytes: the file still begins with 89 50 4E 47 0D 0A 1A 0A, the PNG signature. A library reading it reports the format as PNG, not JPG. And the rendered image still had 114,775 fully transparent pixels out of 160,000 — transparency that no lawful JPG can contain, because the JPG format has no alpha channel.
So the rename produces a file that displays correctly, still is a PNG, and is silently mislabelled. It is the worst of the three outcomes: not an obvious failure, and not a conversion. Any tool that trusts the extension instead of the first bytes will now read a PNG as a JPG, and the first thing that breaks is usually the alpha channel, because that is the thing the JPG format cannot hold.
A JPG has no alpha channel. This file has 114,775 transparent pixels and a .jpg name.
For completeness, the one control the converters all put front and centre. I converted the truecolour PNG at four quality settings and measured each output against the PNG's own decoded pixels — not against another JPG.
| Quality | JPG bytes | PSNR | Pixels changed | Over 2 levels | Worst pixel |
|---|---|---|---|---|---|
| 75 | 93,220 | 43.04 dB | 97.9208% | 20.9980% | 50 |
| 85 | 160,573 | 43.72 dB | 97.0673% | 17.3330% | 38 |
| 92 | 321,931 | 44.53 dB | 96.2243% | 13.2176% | 36 |
| 95 | 526,556 | 45.11 dB | 95.6282% | 10.5445% | 32 |
PSNR is in decibels and higher is better. The column that matters is not PSNR, it is the last two. At quality 75 the worst pixel is 50 levels away from the original and 20.9980% of the image moved by more than 2 levels. At 95 the worst pixel is 32 and the count is 10.5445%. Between 75 and 95 the file grows 5.65× and the worst-pixel error falls by 18 levels — from a difference you can see on a hard edge to one you usually cannot.
Note what the quality slider did not change. It did not change the component count, it did not change the sampling factors, and it did not change whether transparency existed. Those were settled before the slider was touched. The quality setting only decides how precisely the blocks are coded — and it moves the byte count much more than it moves the picture.
89 50 4E 47, nothing was converted — the file was only renamed.Related: batch convert PNG to JPG, where transparency comes from, cutting PNG bytes, what the quality slider does to one file.
Decode the PNG and re-encode it as a JPEG — the format change has to happen in the bytes, not in the file name. Renaming a PNG to .jpg does not do it: the file keeps the PNG signature 89 50 4E 47, a library still reports it as PNG, and the transparency inside it survives, which no JPG can hold. Read the PNG's colour type first, because that decides the shape of the JPG you get. On my test, colour type 0 and colour type 2 produced JPGs that differed by 19,362 bytes while decoding to byte-identical pixels.
Pick the fill colour before you convert, not after. A JPG has no alpha channel, so every transparent pixel has to become an opaque one. In a browser canvas the default is to multiply the stored colour by the alpha value, which turns fully transparent pixels black and darkens every semi-transparent one. I measured the formula as JPG = stored RGB × alpha ÷ 255, verified to within 1 level across 8 sample points; painting a background first gives stored RGB × alpha ÷ 255 + 255 × (1 − alpha ÷ 255), also verified to 1 level.
No, and the failure is quiet rather than loud. I renamed a PNG with a transparent background to .jpg, served it under an image/jpeg content type, and the browser rendered it without complaint — but the first eight bytes were still the PNG signature, a library reported the format as PNG, and 114,775 of 160,000 pixels were still transparent. The file displayed, was not a JPG, and nothing said so.