What compression actually throws away

Every guide to image compression says it "reduces file size with minimal quality loss", which is true and tells you nothing. What is actually being removed, and why can you not see it?

The answer is specific enough to be useful, and it explains the two things people get wrong most often: why the quality number is not a percentage of anything, and why compressing a file that has already been compressed does more damage than the first pass did.

Lossless and lossy, in one paragraph each

Lossless compression finds repetition and writes it down once. A screenshot with a thousand identical white pixels in a row stores that as "white, a thousand times". Nothing is discarded, the original comes back exactly, and the saving depends entirely on how repetitive the picture is. PNG, lossless WebP and GIF all work this way.

Lossy compression throws information away and keeps a picture that looks close enough. It is not a smaller copy of your image; it is a different image that your eye reports as the same one. JPEG, lossy WebP and AVIF all work this way, and they are the reason a photograph can be a twentieth of its raw size and still look fine.

What a JPEG encoder actually discards, in order

The steps are worth knowing because they explain every artefact you have ever seen.

  1. Colour resolution goes first. Your eye is far better at seeing changes in brightness than changes in colour, so the encoder separates the two and keeps only one colour sample for every four pixels. Half the colour data is gone before anything else has happened, and on a photograph you will not notice. On a red logo against white you will: that is the faint coloured fringe on hard edges.
  2. The image is cut into eight-by-eight blocks. Each block is described not as sixty-four pixels but as a set of frequencies: how much flat tone, how much gentle variation, how much fine detail. This is a lossless step on its own. It is what makes the next one possible.
  3. The fine detail is rounded off. High-frequency components are divided by a table of numbers and rounded, and the quality setting is what scales that table. Round hard and the fine detail in each block becomes zero, which compresses to almost nothing. This is the entire lossy step, and everything you dislike about a low-quality JPEG happens here.

Where the artefacts show up, and why

Because the encoder works in blocks and rounds off fine detail, its errors appear exactly where fine detail is: at high-contrast edges. Black text on white is the worst case anyone encounters, which is why a JPEG screenshot of a document has a faint grey mist around every letter while a JPEG of a landscape looks perfect at the same setting.

The second place is flat, gently graded areas: a clear sky, a studio backdrop, skin. There is so little detail to describe that the rounding becomes visible as bands or blotches. This is why a photograph of a sunset often compresses worse than a photograph of a forest, which is the opposite of what people expect.

The practical rule follows directly. Pictures of the world go to JPEG or WebP. Pictures of a screen stay lossless — PNG or lossless WebP. Choosing by the content of the image rather than by the file size you want is the single decision that fixes most compression complaints.

Generation loss: why the second pass costs more than the first

Compress a photograph at 85% and you get a file that is visually identical to the original. Open that file, save it again at 85%, and something subtler happens: the encoder is no longer looking at your photograph. It is looking at the previous encoder's output, block boundaries and rounding errors included, and it treats those artefacts as detail worth preserving while introducing its own on top.

The effect compounds. One pass is free. Two is invisible. By five you can see softening around text and blotching in flat areas, and by ten the image has a distinctly plastic quality that no amount of care will remove. Nothing about this is unique to JPEG; every lossy format does it, and converting JPG to WebP counts as a pass.

So the rule that matters more than any quality setting: keep one original and always work from it. Never edit and re-save the copy you exported last time. If you have to compress a file that is already compressed, accept that you are spending quality you cannot get back, and stop as soon as it fits rather than going as small as you can.

How small should you actually go?

There is no correct number, only a trade you should be making deliberately. For a web page, 75 to 85% is the range where almost nobody can tell in a side-by-side comparison and the file is a fraction of the original. For something being printed, or a photograph you are keeping, stay above 90%. If a form has given you a hard limit, aim at the limit rather than at a quality number: compressing to a size searches for the highest quality that clears it, which is a better answer than guessing at a slider.

One more thing worth doing before you compress anything: check the dimensions. A 4000-pixel-wide photograph displayed in a 800-pixel column is carrying twenty-five times the data it needs, and no quality setting fixes that. Resize it first, then compress, and the same file size buys a dramatically better-looking picture.

How to check your own file rather than trust a number

Open the original and the compressed version side by side at 100% zoom, not fitted to the window, and look at three things: the edges of any text, the largest area of flat colour, and any place where something dark meets something bright. If those three are clean, the rest of the picture is. If they are not, you have gone too far, and the fix is a higher quality setting or fewer pixels rather than a different tool.

Questions

Is there any way to compress without losing quality?

Only with a lossless format, and only up to a point. PNG, lossless WebP and a zip file all compress without discarding anything, but they work by finding repetition, and a photograph has almost none, so the saving is small. The phrase people search for usually means "compress without me being able to see the difference", which is a different and entirely achievable thing: at 80 to 90% quality on a photograph, almost nobody can.

Does resizing an image lose quality?

Making it smaller does not, in any way you would notice: the scaling uses high-quality smoothing and you are throwing away pixels you were not going to display anyway. Making it larger does, because there is no detail to invent. What costs quality in both directions is the re-encode afterwards, which is why resizing and compressing in one pass is better than doing them separately.

How many times can I safely re-save a JPG?

Once is free, twice is invisible, and by about the fifth pass on the same file you can see it, particularly around text and in flat areas of colour. The damage is not linear: each pass compresses the previous pass’s errors as though they were part of the picture. The practical rule is to keep one original and always work from it, rather than editing and re-saving the copy you last exported.

Is 80% quality 80% as good?

No, and the number is not a percentage of anything you would recognise. It scales the tables the encoder uses to decide how much of each block to round off, and its effect on file size is steep and non-linear. Dropping from 100 to 90 typically halves the file and changes nothing visible. Dropping from 50 to 40 saves very little and looks distinctly worse. The useful range is 75 to 90.

Related: compress an image, choosing between JPG, PNG, WebP and AVIF, and why PDFs get so large.