Media & Files

Lossy vs Lossless Image Compression: What Actually Happens to Your Pixels

How PNG shrinks an image without losing a pixel, how JPEG throws detail away to get ten times smaller, what generation loss really is, and how to choose the right trade-off.

When you save an image, the format has to decide how to pack millions of pixels into a small file. There are two strategies, and the choice between them is the single biggest factor in how your image looks and how large it is. Lossless compression keeps every pixel exactly; lossy compression deliberately throws some away. This article explains what each one actually does to your data — and why the “wasteful” one is the right choice for photographs.

You can watch the trade-off live in the Universal Image Converter: convert the same image to PNG and to JPEG and compare the file sizes, or slide the JPEG quality control and see the size move.

Why images compress at all

A raw, uncompressed image stores one colour value per pixel with no cleverness — a modest 12-megapixel photo is about 36 MB raw. Real images are nowhere near that random, though: skies are smooth, edges repeat, neighbouring pixels are usually similar. Compression exploits that redundancy. The question is only whether it is allowed to lose anything in the process.

Lossless: perfect reconstruction

Lossless compression rewrites the data so the exact original can be rebuilt — zero pixels changed. Two ideas do most of the work:

  • Run-length encoding — a run of 400 identical sky-blue pixels is stored once as “this colour, 400 times.” Brilliant for flat areas, useless for noise.
  • Dictionary / entropy coding (DEFLATE, the engine inside PNG and ZIP) — common patterns get short codes, rare ones get long codes, so the average shrinks. PNG also filters each row first, storing the difference from the pixel above or to the left, which turns smooth gradients into long runs of small numbers that compress beautifully.

Because nothing is discarded, you can save, edit and re-save a PNG forever with no degradation. The cost is size: on a noisy photograph there is little repetition to exploit, so a lossless file stays large. PNG, GIF, BMP, TIFF, QOI and lossless WebP/AVIF all live here.

💡Lossless shines on graphics: screenshots, logos, line art, diagrams, anything with large flat colour areas and crisp edges. There PNG is both smaller and sharper than JPEG.

Lossy: discarding what the eye ignores

Lossy compression makes a bet: the human eye is far more sensitive to brightness than to fine colour detail, and barely notices subtle high-frequency texture. So it throws that information away. JPEG’s pipeline is the classic example:

  1. Colour transform — convert RGB to luma (brightness) plus two chroma (colour) channels, then often store colour at half resolution. You rarely notice; that is “chroma subsampling.”
  2. Frequency transform (DCT) — split the image into 8×8 blocks and describe each as a mix of coarse-to-fine wave patterns instead of raw pixels.
  3. Quantisation — this is where data is actually lost: the fine, high-frequency patterns are rounded off, many to zero. The quality slider controls how aggressive this rounding is.
  4. Entropy coding — losslessly pack what remains.

The payoff is enormous: a JPEG can be one-tenth the size of the equivalent PNG and look identical at normal viewing distance. WebP, AVIF and HEIC use more modern versions of the same idea (smarter block sizes and prediction) to do even better. The price is that the discarded detail is gone, and pushed too far, lossy compression shows its hand.

What lossy artefacts look like

ArtefactWhere you see it
BlockingFaint 8×8 squares in smooth areas at low quality
Ringing / mosquito noiseFuzzy halos hugging sharp edges and text
BandingVisible steps across what should be a smooth sky or gradient
Colour bleedColour smearing past edges, from chroma subsampling

This is exactly why text and line art should never be JPEG: their hard edges are full of the high frequencies JPEG discards first, so they come out surrounded by visible fuzz. The same screenshot as a PNG is smaller and crisp.

Generation loss: the photocopy effect

Lossless files can be re-saved endlessly with no harm. Lossy files cannot. Every time you open a JPEG, edit it, and save again, the lossy pipeline runs on the already-degraded pixels, discarding a little more each pass — like photocopying a photocopy. After many cycles a JPEG visibly softens and its artefacts compound.

⚠️Keep a lossless master. Do your editing on a PNG or TIFF original and export a fresh JPEG/WebP/AVIF only when you need to publish. Never use a JPEG as your working copy through many edits.

Choosing the trade-off

  • Photographs for the web — lossy (JPEG, or WebP/AVIF for smaller files). Quality 75–85% is invisible loss at huge size savings.
  • Screenshots, graphics, text, transparency — lossless (PNG), or SVG if it was drawn.
  • Editing masters & archiving — lossless (TIFF, 16-bit PNG) so no quality is ever lost between edits.
  • Maximum compatibility — JPEG (photos) or PNG (graphics) are read by essentially everything.

Whatever you choose, convert from your best original. The Universal Image Converter lets you pick the exact output — lossless PNG/TIFF, or lossy JPEG/WebP/AVIF at a chosen quality — and shows you the resulting file size so you can dial in the trade-off yourself, all without uploading a thing. For the practical question of which modern format wins, see PNG vs JPEG vs WebP vs AVIF.

Frequently asked questions

Is PNG or JPEG better quality?

PNG is mathematically perfect — it stores every pixel exactly. JPEG discards some detail to save space. But on a photograph a high-quality JPEG looks identical to the PNG at a fraction of the size, so "better quality" only matters for graphics with sharp edges, where JPEG introduces visible fuzz and PNG does not.

Does saving a JPEG repeatedly reduce quality?

Yes. Each save re-runs lossy compression on the already-degraded pixels, so detail erodes a little every time — this is generation loss. Editing the same JPEG over and over visibly softens it. Keep a lossless master (PNG or TIFF) and export a fresh JPEG when you need one.

What quality setting should I use for JPEG?

For most web photos, 75–85% is the sweet spot: files are small and artefacts are invisible at normal viewing size. Above ~92% the file grows fast for little visible gain; below ~60% blocky artefacts and colour banding start to show, especially around sharp edges and in smooth skies.

Can I recover the original quality of a compressed JPEG?

No. Lossy compression permanently discards information; there is no button that brings it back. Tools that "enhance" a JPEG are guessing at plausible detail, not recovering the real thing. Always work from the highest-quality original you have.

Was this article helpful?