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:
- Quality 95–100: The quantization divisors are very small. Almost all frequency information is preserved. File sizes are large because there's little data to compress. The difference between quality 95 and 100 is often invisible but doubles the file size.
- Quality 80–95: The sweet spot. High-frequency details that are barely visible are simplified, but the overall image looks nearly identical to the original. File sizes are 40–70% smaller than quality 95+.
- Quality 60–80: More aggressive quantization. Fine textures start to show blocky artifacts, but overall quality is still good. This range is fine for images that will be displayed small on web pages.
- Quality below 60: Heavy quantization. Visible blockiness, color banding, and ringing artifacts around edges. Only suitable when file size is the absolute priority.
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
- For web photos: Quality 75–85 is almost always the right choice. If the image will be displayed small (below 600px), quality 70 is fine.
- For print: Use quality 90–95. Print reveals artifacts that are invisible on screen.
- For archival: Save as PNG or TIFF, not JPEG. Every JPEG save loses information.
- Never re-compress: If an image is already a JPEG, compress at a lower quality than the original, or don't compress at all.
- Use progressive encoding: It's smaller and better for web. CompactJPG uses it by default.
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.