convert2image

What the JPEG quality slider actually changes

Every program that saves JPGs has a quality setting, and almost none of them explain it. It is presented as a single number, as if quality were a volume knob. Underneath, the slider controls one specific step in a pipeline, and knowing how that pipeline works makes the choice much less mysterious.

Step one: split brightness from colour

A JPEG encoder first converts the image from red, green and blue into brightness (called luma) and two colour-difference channels. Our eyes are much sharper at seeing changes in brightness than in colour, and JPEG exploits that immediately.

Most encoders then store the colour channels at half resolution in both directions, a scheme called 4:2:0 chroma subsampling. A quarter of the colour data is gone before any real compression has started, and in photos you almost never notice. Where you do notice is fine coloured detail: thin red text on a blue background, or a coloured line in a chart, picks up soft, bleeding edges. That is one reason screenshots look worse as JPG than photos do.

Step two: 8 × 8 blocks and wave patterns

Each channel is cut into blocks of 8 × 8 pixels. Each block is then re-described using a technique called the discrete cosine transform. Instead of 64 separate pixel values, the block becomes 64 amounts of standard patterns: one flat average, then gradually finer ripples running across, down and diagonally.

This step on its own loses nothing. The point is that in most photos, the flat and gentle patterns carry nearly all the visible information, while the fine ripples have tiny amounts that the eye barely registers.

Step three: rounding, which is where the quality slider lives

Next comes quantisation. Each of the 64 pattern amounts is divided by a number from a table and rounded to a whole number. Large divisors mean coarse rounding; many small values become zero. Runs of zeros compress extremely well in the final step, which is where the size saving comes from.

The quality setting scales that table. High quality means small divisors: fine patterns survive, the file is bigger. Low quality means large divisors: fine patterns are wiped out, and eventually even the gentle ones are rounded so coarsely that neighbouring blocks no longer match at their edges. That mismatch is the blocky look of a badly compressed JPG.

Why quality 100 is not lossless

Even at 100, colour is usually still subsampled, and the conversion between colour systems and the rounding in the transform both lose a tiny amount. A JPEG saved at 100 is extremely close to the original, and also very large, often two to three times the size of the same image at 90, for a difference almost nobody can see. If you truly need lossless, use PNG.

Why the numbers do not match between programs

There is no universal quality scale. The 0 to 100 range comes from the reference software library most programs are built on, but programs are free to map their own settings onto it. Photoshop uses 0 to 12. Some cameras use words like Fine and Normal. Browsers, phone camera apps and image editors all choose slightly different tables. A quality 80 from one tool is roughly, not exactly, a quality 80 from another. Judge the result, not the number.

What the numbers mean in practice

QualityWhat you tend to seeGood for
95–100Indistinguishable from the sourceMasters you will edit further, print files
85–92No visible change in normal viewingSharing photos, high-end web images
70–82Tiny softening of the finest textureMost website photos, email
50–65Visible smoothing, slight blocks in skiesThumbnails, strict upload limits
Below 40Obvious blocks and colour smearsAlmost nothing

The file size curve is steep at the top. Going from 95 down to 85 often halves the file. Going from 75 down to 65 saves much less, while the damage becomes easier to see. That is why the 75 to 85 band is so popular: it sits just before the curve flattens.

The same number, very different results

Because compression works on patterns, what is in the photo matters as much as the setting. A picture of fog or a clear sky has almost no fine pattern in it, so it compresses to a tiny file even at high quality. A picture of gravel, dense foliage or a crowd is packed with fine pattern, and at the same setting produces a file several times larger. High ISO noise from a dark scene is fine pattern too, and bloats the file.

So a fixed quality number gives consistent look across photos, not consistent size. If you need to fit under a size limit, reduce the pixel dimensions first. It is far more effective than pushing quality down, and it hurts the picture less.

Generation loss

The last thing to know is that the rounding compounds. Open a JPG, make a change, save it as JPG again, and it goes through the whole pipeline again with new rounding errors on top of the old ones. After a handful of rounds, colours start to drift and edges get crunchy. Messaging apps and social networks that re-compress uploads add rounds you do not control.

The fix is simple discipline: keep an original, do your edits on a lossless copy or in an editor's native format, and export a JPG once, at the end.