Back to Blog

What the JPEG Quality Slider Actually Does (It's Not What You Think)

Most users treat the JPEG quality slider as a simple fidelity percentage: 100 means a perfect copy, 50 means half the original quality. While this idea is common, it is simply not how the compression works. Understanding what the quality parameter actually controls can help you make better decisions about your images.

The DCT: How JPEG Actually Works

JPEG compression starts by dividing the image into 8×8 pixel blocks. Each block is transformed from spatial data (pixel colors) into frequency data using the Discrete Cosine Transform (DCT). The result is a set of 64 frequency coefficients for each block — representing how much of each spatial frequency pattern is present.

Low-frequency coefficients represent smooth gradients (large areas of similar color), while high-frequency coefficients represent fine details (sharp edges, textures, noise). This is the key insight: the human eye is much more sensitive to low-frequency information than high-frequency information.

Quantization: Where Quality Actually Matters

After the DCT, JPEG applies quantization — dividing each frequency coefficient by a value from a quantization table, then rounding to the nearest integer. This is where data is irreversibly lost. Large divisors produce more zeros (which compress better) but lose more information. Small divisors preserve more data but result in larger files.

The quality parameter controls the quantization tables. When you set quality to 80, the encoder scales the base quantization tables so that the divisors are relatively small — preserving most frequency information. Quality 50 uses larger divisors, which zeroes out more coefficients and creates more compression artifacts.

Why Quality 80 ≠ 80% of the Original

The quality number is not a percentage of visual quality. It's a scaling factor applied to the reference quantization tables defined by the JPEG standard (the IJG tables). Here's what actually happens at different quality levels:

Progressive JPEGs: A Free Optimization

There's another setting that affects JPEG quality and file size: progressive encoding. A progressive JPEG stores the image data in multiple scans, from coarse to fine. When loading over a slow connection, the browser can display a low-quality preview almost immediately and gradually refine it.

But progressive encoding also has a practical benefit: it typically produces smaller files than baseline encoding. The multi-scan structure allows the encoder to optimize the Huffman tables across the entire image, resulting in 2–10% smaller files at the same quality setting.

CompactJPG uses progressive encoding by default — it's strictly better for web images.

Detecting Existing Quality

One of the most common mistakes in image compression is re-compressing a JPEG that's already been compressed. If your image was originally saved at quality 75, re-encoding it at quality 80 won't improve it — it will only make the file larger while adding a second generation of compression artifacts.

CompactJPG avoids this by detecting the original quality from the image's DQT (Define Quantization Table) markers. If the target quality isn't lower than the original, it returns the original file unchanged.

Practical Recommendations

The quality slider is a powerful tool when you understand what it controls. It's not a simple percentage — it's a dial that scales how aggressively the encoder simplifies frequency information. And now that you know how it works, you can make informed decisions about quality versus file size.