HandyVale › Guides

Change PNG to JPG: The Header Decides the Shape of the File You Get

Updated 2026-11-02 · handyvale.com

Short answer

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.

Browser-side processing — your images are never uploaded · No login · No watermark · No file-size or use limit

Six PNGs, one picture

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 asColour typeBit depthExtra chunkPNG bytes
Truecolour28—3,351,429
Truecolour + alpha68—3,659,146
Grayscale08—1,554,802
Grayscale + alpha48—1,759,517
16-bit016—1,759,901
Indexed, 64 colours38PLTE1,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.

One header decides the output IHDR colour type bit depth type 0 one component · luma only type 2 three components · Y Cb Cr type 3 palette expands to three components type 6 alpha has to go somewhere The JPG header then reports components and sampling.

The header does not describe the picture. It describes the storage, and the storage is what the encoder has to honour.

The same picture, two component counts

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 → JPGComponentsSamplingBytes
Direct, luma only11×1288,835
Forced through RGB32×2 / 1×1 / 1×1308,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.

Same picture, same pixels, 19,362 extra bytes 1 component · luma 1×1 288,835 bytes 3 components · 2×2 + 1×1 + 1×1 308,197 bytes +19,362 bytes  (+6.70%) 0 of 3,840,000 pixels differ between the two decoded files

The extra bytes are not error and they are not detail. They are two empty chroma planes.

Full chroma on a picture with no colour

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 sourceJPG bytesCostPixels changed
4:2:0 chroma308,197——
4:4:4 chroma349,130+40,933 (+13.28%)0
4:4:4 on the truecolour source381,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.

The palette advantage inverts

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 picturePNG bytesJPG bytesRatio
Truecolour PNG3,351,429321,9310.0960×
Palette PNG, 64 colours1,022,911327,6610.3203×
Difference3.28× smaller5,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.

Transparency flattens to black in a browser

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 areaBrowser JPG cornerLibrary route
Black0, 0, 00, 0, 0
Magenta0, 0, 0255, 0, 255
White0, 0, 0255, 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.

What the viewer shows, and what you get viewer on white browser JPG gap a=0 255 a=72 183 a=145 110 a=218 37 a=255 1 Formula verified to 1 level across all 8 sample points.

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.

Renaming a PNG to .jpg does nothing

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.

The name changed. The bytes did not. First eight bytes, after renaming 89504e47 0d0a1a0a PNG signature, unchanged What reads it back browser: renders library: says PNG not a JPG Alpha pixels still in the file 114,775 transparent 45,225 opaque

A JPG has no alpha channel. This file has 114,775 transparent pixels and a .jpg name.

What the quality slider is actually adjusting

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.

QualityJPG bytesPSNRPixels changedOver 2 levelsWorst pixel
7593,22043.04 dB97.9208%20.9980%50
85160,57343.72 dB97.0673%17.3330%38
92321,93144.53 dB96.2243%13.2176%36
95526,55645.11 dB95.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.

Converting one PNG without the surprises

  1. Read the PNG's colour type and bit depth first. They decide whether the JPG will have one component or three, and whether your source has colour at all.
  2. If it is colour type 0 or 4, ask for a grayscale JPG if the tool offers one, or expect a 3-component file carrying empty chroma planes.
  3. Do not pay for 4:4:4 chroma on a grayscale source. It cost 13.28% more bytes and changed 0 pixels in my test.
  4. If the PNG is a palette PNG (colour type 3), keep it as a PNG. The palette is why it is small, and the JPG cannot hold it.
  5. If it has transparency, paint the background you want before converting. The default is a multiply by alpha, which darkens every semi-transparent pixel.
  6. Check the output's first bytes. If they are 89 50 4E 47, nothing was converted — the file was only renamed.
  7. Set quality last, and compare the two settings side by side at 100%. The number on the slider is not the size of the difference you will see.
Your call, not ours: whether 6.70% matters. The three-component file holds two chroma planes that carry nothing, and it decodes to the same picture. If the file goes over the wire, 19,362 bytes is 6.70% of the transfer. If the file sits on a disk nobody looks at twice, it is a detail.
Your call, not ours: whether a black or white background is right for your transparent pixels. I can tell you what a browser canvas does by default, and that the library route I tested kept the colour stored under the alpha instead. Which one your tool does, and which one your brand wants, I have not measured.
Your call, not ours: how much of the 255-level gap between the viewer and the converted file is acceptable to you. On a logo with a soft edge, the difference is the edge. On a screenshot with a drop shadow, it is the shadow. Only you know which assets are on the receiving end.

Related: batch convert PNG to JPG, where transparency comes from, cutting PNG bytes, what the quality slider does to one file.

Questions

How do I change my PNG file to JPG?

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.

How can I convert a PNG image to JPG?

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.

Can I just rename a PNG to JPG?

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.