How image compression works

Image3 min read

The difference between lossy and lossless, what a JPEG actually discards, and why a screenshot and a photograph behave completely differently at the same setting.

In short

Lossless compression finds exact repetition and keeps every pixel. Lossy compression discards detail your eye is least likely to notice. Photographs suit lossy formats; text and flat graphics do not.

An uncompressed photo is one number per colour channel per pixel. A 12-megapixel phone photo is around 36MB that way. The JPEG on your phone is two or three, so something is removing more than 90% of it. There are two completely different methods for doing that, and knowing which one you are using explains almost every surprise about image file sizes.

Lossless: keep everything, store it cleverly

Lossless compression finds patterns and repetition and writes them down more briefly. A row of 400 identical white pixels becomes a note saying "400 white pixels". Decompress it and you get back exactly what you started with, pixel for pixel.

This works brilliantly on flat colour, sharp edges and repeated structure — logos, screenshots, diagrams, line art. It works poorly on photographs, where almost no two adjacent pixels are identical and there is very little exact repetition to find. PNG is the common lossless format.

Lossy: throw away what you won't miss

Lossy compression takes a different approach: decide what the eye is least sensitive to, and store that part badly. JPEG divides the image into 8×8 blocks and describes each as a set of frequency components — broad tonal shifts plus progressively finer detail. Then it rounds the fine detail off, and the more aggressively it rounds, the smaller the file.

It also stores colour at lower resolution than brightness, because human vision resolves brightness far more sharply than hue. That alone is a large saving before any quality setting is applied.

What the quality slider does

The quality value passed to a JPEG or WebP encoder sets how coarsely that rounding happens. It is not a percentage of anything meaningful — 50% quality does not mean half the detail — it is a dial on the encoder's aggressiveness.

Roughly what to expect from a photograph at each quality level
QualityResult
90–100Visually identical to the source; files stay large. Rarely worth it for the web.
70–85The useful range. Very hard to tell from the original at normal viewing size.
50–70Visible on close inspection: softening in texture, slight blockiness in flat areas.
Below 50Obvious artefacts — haloed edges, blotchy skies, muddy detail.

Dexta's Compress Image starts at 72%, which sits in the useful range for photographs. The slider does nothing at all for a PNG output, because PNG is lossless and has no quality parameter to set — the tool disables it and offers WebP conversion instead.

Compression is not resizing

These are different operations and they are often confused. Compressing stores the same number of pixels less precisely. Resizing reduces the number of pixels. For a large photo destined for a small display, resizing usually saves more than any quality setting — and the two together save more than either alone.

Mistakes worth avoiding

  • Re-saving a JPEG repeatedly. Lossy compression is not idempotent; each pass discards more, and it accumulates visibly after a few rounds.
  • Using JPEG for anything with text, sharp edges or transparency. Use PNG or WebP.
  • Editing a compressed copy instead of the original. Do the edits first, compress once at the end.
  • Assuming a big percentage saving on an image that has already been compressed — there is much less left to remove.