In the world of image compression, one number keeps coming back: 75. Look at almost any compression tool's default settings and the quality factor is preset somewhere near this value. It is neither an engineering guess nor an arbitrary committee decision — it falls out of the mathematical structure of the JPEG algorithm itself. This article walks through the full JPEG compression pipeline, breaks the "quality factor" down to the level of quantization-table scaling, and shows you exactly why 75 is the sweet spot between file size and visual quality.
1. The JPEG Compression Pipeline at a Glance
JPEG (Joint Photographic Experts Group) is a lossy compression standard. Its core idea is to exploit the human visual system's sensitivity to brightness, its relative insensitivity to color, and its tolerance for high-frequency detail, discarding information that is hard to perceive. The pipeline has five stages.
Stage 1 — Color Space Conversion: RGB → YCbCr
Source images are usually stored in RGB (red, green, blue), but JPEG first converts them to the YCbCr color space:
- Y: Luminance, the brightness information
- Cb: Blue chrominance
- Cr: Red chrominance
The conversion formulas are:
Y = 0.299·R + 0.587·G + 0.114·B
Cb = -0.1687·R - 0.3313·G + 0.5·B + 128
Cr = 0.5·R - 0.4187·G - 0.0813·B + 128
This step exists because the eye is extremely sensitive to luminance changes (it can resolve fine brightness differences) but relatively insensitive to chrominance. The Cb and Cr channels can therefore be downsampled aggressively (4:2:0 chroma subsampling) while Y is kept at full resolution. This single step typically halves the data with almost no perceptual loss.
Stage 2 — 8×8 Block Splitting and Level Shift
The image is divided into 8×8 pixel blocks. Each pixel value ranges from 0 to 255; to make the subsequent DCT computation cleaner, 128 is subtracted from each value to center the range at -128 to 127.
Stage 3 — Two-Dimensional Discrete Cosine Transform (DCT)
Each 8×8 block is transformed with a 2D DCT, moving the data from the spatial domain to the frequency domain. The result is an 8×8 coefficient matrix. The top-left corner holds the DC coefficient (the block's average brightness); moving toward the bottom-right, the AC coefficients represent progressively higher frequencies — fine detail, edges, and texture.
The DCT itself is reversible and lossless, but it reorganizes the information by visual importance: low-frequency coefficients carry the main shape of the image, high-frequency coefficients mostly carry detail and noise. This sets up the lossy step that follows.
Stage 4 — Quantization: Where the Loss Happens
DCT coefficients are floating-point numbers and cannot be encoded directly. JPEG divides each coefficient by a corresponding entry from an 8×8 quantization table, producing integers. The larger the divisor, the coarser the result and the more information is thrown away.
There are two tables: one for luminance, one for chrominance. The standard JPEG luminance table has small values in the top-left (e.g. 16) and large values in the bottom-right (e.g. 99) — exactly exploiting the eye's insensitivity to high frequencies so they can be discarded more aggressively.
This is the only lossy step in the entire pipeline, and it is exactly where the quality factor does its work.
Stage 5 — Entropy Coding: Lossless Finish
The quantized coefficients are scanned in ZigZag order (from low to high frequency), run-length encoded (RLE) to compress runs of zeros, then compressed further with Huffman or arithmetic coding. This stage is fully lossless — it only packs the data more tightly.
The full pipeline looks like this:
2. What the Quality Factor Actually Controls
Many people assume the quality factor (Q) is a 0–100 "quality score." It is not. What it really controls is the scaling of the quantization table.
The Quantization Table Scaling Formula
JPEG defines a baseline quantization table. The quality factor does not replace the table — it scales every entry according to this formula:
If Q >= 50:
scale = 5000 / Q
If Q < 50:
scale = 200 - 2·Q
quant_value = floor((baseline_value × scale + 50) / 100)
quant_value = clamp(quant_value, 1, 255) # min 1, max 255
Key takeaways from this formula:
- Q = 100: scale = 50, quantization values are about half the baseline, almost no information is lost (but quantization error still exists, so JPEG is never truly lossless).
- Q = 50: scale = 100, the quantization values equal the baseline — this is the JPEG standard's reference point.
- Q = 75: scale = 5000/75 ≈ 66.7, the quantization values are about 2/3 of the baseline — slightly looser than the reference.
- Q < 50: scale exceeds 100, quantization becomes increasingly coarse and high-frequency detail is wiped out.
- Q = 1: scale = 198, almost all high-frequency coefficients are zeroed and block artifacts become obvious.
Why 75 Is the Sweet Spot
The key is the marginal return on the quantization curve. From Q50 to Q75, file size drops sharply while visual quality loss is minimal; from Q90 to Q95, file size balloons while the quality gain is essentially invisible to the eye.
Consider a concrete comparison: using Q95's size as the 100% baseline, Q75 typically lands at around 30%–35%, while PSNR (peak signal-to-noise ratio) drops only 2–3 dB and SSIM (structural similarity) drops by less than 0.05. In other words, Q75 trades 1/3 of the file size for over 95% of the visual quality. That is the fundamental reason it became the default — it sits right on the edge of visually lossless compression, and going any further is wasteful.
Notice where Q75 sits on the chart: the size bar has dropped to 32% while the quality curve still hovers near 90% — this is the geometric meaning of the "sweet spot."
3. Measuring Different Quality Factors in Python
The script below uses Pillow (PIL) to compress the same image at different quality factors and print a comparison. You can run it directly to verify the conclusions above.
from PIL import Image
from io import BytesIO
import os
def compress_jpeg(img_path, quality):
"""Compress the image at the given quality factor, return byte size."""
img = Image.open(img_path).convert('RGB')
buffer = BytesIO()
img.save(buffer, format='JPEG', quality=quality, optimize=True, subsampling=2)
return buffer.tell()
def compare_qualities(img_path):
original_size = os.path.getsize(img_path)
print(f"Source file: {img_path}")
print(f"Original size: {original_size / 1024:.1f} KB")
print(f"{'Quality':<10}{'Size(KB)':<12}{'Ratio':<10}{'Saved':<12}{'vs Q95':<10}")
print("-" * 58)
sizes = {}
for q in [95, 85, 75, 65, 50, 30, 10]:
size = compress_jpeg(img_path, q)
sizes[q] = size
ratio = original_size / size
saving = (1 - size / original_size) * 100
rel = size / sizes[95] * 100 if q != 95 else 100
print(f"Q{q:<8}{size/1024:<12.1f}{ratio:<10.2f}{saving:<12.1f}{rel:<10.1f}")
# Report Q75 savings vs Q95
if 95 in sizes and 75 in sizes:
saved = (1 - sizes[75] / sizes[95]) * 100
print(f"\nQ75 saves {saved:.1f}% vs Q95")
if __name__ == '__main__':
compare_qualities('sample.jpg')
Typical output (using a 4000×3000 landscape photo):
Source file: sample.jpg
Original size: 5823.4 KB
Quality Size(KB) Ratio Saved vs Q95
----------------------------------------------------------
Q95 1245.8 4.67 78.6% 100.0
Q85 722.5 8.06 87.6% 58.0
Q75 398.7 14.61 93.2% 32.0
Q65 274.2 21.24 95.3% 22.0
Q50 186.9 31.16 96.8% 15.0
Q30 99.5 58.52 98.3% 8.0
Q10 49.8 116.91 99.1% 4.0
Q75 saves 68.0% vs Q95
The numbers confirm the earlier conclusion: Q75 cuts about 68% of the size compared to Q95, while the two images are virtually indistinguishable at normal screen viewing distance.
4. Common Image Formats Compared
With JPEG understood, it helps to place it in the wider image-format ecosystem. Each format embodies a different compression philosophy.
| Format | Compression | Transparency | Animation | Typical Ratio | Best Use Case |
|---|---|---|---|---|---|
| JPEG | Lossy (DCT) | No | No | Medium-high | Photos, natural-color images, web thumbnails |
| PNG | Lossless (DEFLATE) | Yes (8bit/16bit) | No | Low | Icons, UI elements, text screenshots, transparency |
| WebP | Lossy + Lossless | Yes | Yes | High (25%–35% smaller than JPEG) | Modern photos, animation replacement, minimal size |
| TIFF | Lossless / Lossy (optional) | Yes | No | Low | Print, scanning, professional archiving |
| BMP | Uncompressed | No | No | Very low (raw pixels) | Not recommended, legacy only |
A few notes:
- JPEG has no transparency: its biggest shortcoming. Icons needing a transparent background must use PNG or WebP.
- PNG is the lossless "heavyweight": perfect quality but large files — a 4000×3000 photo saved as PNG can exceed 20 MB.
- WebP is JPEG's strongest rival: in lossy mode it is 25%–35% smaller than JPEG at equivalent quality, with transparency and animation support. Its weakness is incomplete support in older browsers and some toolchains.
- TIFF/BMP are not suitable for the web: they belong to professional workflows or exist as legacy formats.
5. Resolution and Quality Factor Work Together
Many people obsess over the quality factor while ignoring resolution, which is actually the more powerful lever. In practice, lowering resolution often yields bigger size savings than lowering quality.
The Two-Step Strategy
A 4000×3000 (roughly 12-megapixel) original photo saved directly as JPEG at Q95 can exceed 4 MB. But a screen typically only needs 1920×1080 (about 2 megapixels), so there is a huge amount of redundancy.
The two-step optimization:
- Step 1 — Lower the resolution. Scaling from 4000×3000 down to 1920×1080 drops the pixel count from 12M to 2M, a reduction of about 83%. Because JPEG size is roughly proportional to pixel count, this step alone removes about 75%–83% of the bytes.
- Step 2 — Adjust the quality factor. At the new resolution, drop Q95 to Q75. Since the downscaling has already smoothed out much of the high-frequency detail, Q75's block artifacts are nearly invisible at this resolution, removing another ~50% of the bytes.
Combined, the final size is about 8%–10% of the original. A 4 MB source image can be reduced to 300–400 KB with a screen-viewing experience that is essentially lossless.
There is an important ordering rule here: lower the resolution first, then lower the quality factor. Doing it the other way around (compressing quality before scaling) causes the scaler to amplify JPEG's block artifacts, making the result look worse.
6. A Format Selection Decision Tree
When you have an image in hand, which format should you pick? This decision tree gives a quick answer:
In short: photos go to JPEG or WebP, icons and text go to PNG, and anything needing transparency should avoid JPEG.
7. FAQ: Three Common Questions
Q1: Why is Q75 considered the "best" quality factor?
Because the quantization curve has an inflection point here. Q75 corresponds to a scale of about 66.7, compressing the quantization table to roughly 2/3 of its baseline. At this point, the low-frequency coefficients the eye is most sensitive to are preserved almost intact, while the visually unimportant high-frequency coefficients start to be discarded reasonably. Pushing higher to Q85 or Q95 inflates file size far faster than it improves quality; pushing lower to Q60 or Q50 makes block artifacts and ringing visible. Q75 sits squarely in the zone where size drops fast and quality drops slowly, which is why it is so widely used as a default. Note that "best" is relative to web screen display — professional printing or archival may need Q90 or higher.
Q2: Can WebP completely replace JPEG?
On compression efficiency, WebP's lossy mode is 25%–35% smaller than JPEG at equivalent SSIM, and it supports transparency and animation, so it is technically superior. But "complete replacement" is still not feasible, for three reasons. First, some older browsers and image-processing libraries do not fully support WebP. Second, WebP encoding was slower than JPEG in early implementations (though modern libraries have largely closed this gap). Third, JPEG has had 30 years of ecosystem saturation — camera output, CMS platforms, email attachments all support it flawlessly. A common engineering practice is to output both JPEG and WebP versions and let the browser choose via the <picture> tag.
Q3: What happens if the same image is re-compressed as JPEG repeatedly?
Distortion accumulates, and it is irreversible. Each JPEG compression re-runs quantization and DCT; the block artifacts and ringing introduced by the previous pass are treated as "image content" and quantized again, so artifacts become progressively more visible and quality degrades in a staircase pattern. This phenomenon is called "generation loss." The fix is to keep a lossless master (PNG/TIFF or JPEG at Q100) and derive every variant from that master — never re-compress an already-compressed JPEG. If multiple edits are unavoidable, save working versions in a lossless intermediate format (PSD, TIFF) and only compress to JPEG at final output.
8. Summary and Parameter Cheat Sheet
The core of JPEG compression is trading frequency-domain information for file size, and the quality factor is essentially a knob that scales the quantization table. Q75 is the magic number because it lands precisely on the inflection point of the quantization curve: going higher inflates size without perceptible quality gain; going lower starts to make block artifacts visible. Combined with sensible resolution reduction, Q75 lets a multi-megapixel photo appear on the web at a few hundred kilobytes with negligible visual loss.
Once you understand the principles, parameter selection stops being guesswork. This cheat sheet is for everyday reference:
| Scenario | Recommended Format | Quality Factor | Resolution | Expected Size |
|---|---|---|---|---|
| Web article image (photo) | JPEG | 75–80 | Long edge ≤ 1920px | 200–400 KB |
| Web thumbnail | JPEG | 70 | Long edge ≤ 400px | 15–40 KB |
| Icon / UI element | PNG | — | Original | Varies |
| Text screenshot | PNG | — | Original | Varies |
| Transparent background | WebP / PNG | — | Original | — |
| High-res photo archive | JPEG | 90–95 | Original | 2–5 MB |
| Print output | TIFF / PNG | — | ≥ 300 DPI | Unlimited |
| Modern site, minimal size | WebP | 75–80 | Long edge ≤ 1920px | 150–300 KB |
Master the main line — color space conversion → DCT → quantization → entropy coding — understand how the quality factor scales the quantization table, then combine it with resolution reduction and format choice, and image compression turns from "tuning parameters by feel" into an evidence-based engineering decision.
Related Reading: