JPEG vs PNG Compression Explained: Choosing the Right Image Format

JPEG and PNG are not two grades of the same idea. They are two different philosophies about what a compressor is allowed to throw away. JPEG is lossy: it is permitted to change your pixels, betting that you will not notice the difference. PNG is lossless: every pixel that comes out is bit for bit the pixel that went in. Choosing between them is not about picking the better format, because there is no better format. It is about matching the compressor's assumptions to the kind of picture you actually have.

JPEG works by splitting the image into small blocks and running a discrete cosine transform on each one, which restates the block as a mixture of coarse and fine patterns. Human vision is far more sensitive to broad brightness changes than to fine detail, especially in colour, so the encoder quantises the fine coefficients aggressively and keeps the coarse ones. Quality settings simply control how brutal that quantisation is. Inside a PDF this is the DCTDecode filter, and a JPEG stored in a PDF is normally the original compressed bytes passed straight through rather than re-encoded.

PNG takes the opposite route. It first applies a prediction filter to each row so that each pixel is stored as a small difference from its neighbours, then compresses the result with DEFLATE, a member of the same LZ family that zip uses. Repetition is what it feeds on: a flat background, a solid colour box or a sharp black line on white shrinks dramatically, and nothing is approximated. PDF uses that same algorithm as its FlateDecode filter for text streams and image data alike, which is why the two technologies feel like relatives.

The failure modes tell you the rule. Save a screenshot as JPEG and you get faint halos and mottling around the crisp text edges, because those edges are exactly the fine detail the transform was designed to discard. Save a photograph as PNG and nothing looks wrong, but the file can be several times larger, because a photograph has almost no exact repetition to exploit. So continuous tone material, including page scans that carry paper texture and shading, belongs in JPEG, while screenshots, diagrams, logos and line art belong in PNG. Purely black and white scans are a third case, which is why PDF also supports specialised bilevel filters such as JBIG2.

This is directly useful when you assemble or shrink documents. When building a file with Image to PDF, feeding photographs as JPEG and diagrams as PNG gives you a smaller file and cleaner output than converting everything to one format first. When exporting with PDF to Image, pick the format by what the page contains rather than by habit. And it explains what compress on PdfWill actually does: it recompresses the embedded images, where the real weight sits, while leaving the text layer untouched, so your words stay sharp and selectable no matter how much the pictures shrink.

Related tools