How image compression actually works — and when it hurts quality
JPEG DCT blocks, PNG filters, WebP and AVIF, lossy vs lossless, generational loss, and exactly what the quality slider is trading. Practical rules for photos, screenshots, logos and print.
Most “make this photo smaller” tools hide the real decisions behind a single quality slider. Understanding what actually happens to the pixels helps you pick the right setting (or format) instead of guessing.
Lossy vs lossless — the only distinction that matters
Lossless (PNG, TIFF, some WebP) keeps every single pixel value exactly as it was. It compresses by finding repeating patterns and using smarter encoding, never by throwing data away. Great for screenshots, diagrams, logos, UI assets, and anything with flat colors or sharp edges.
Lossy (JPEG, most WebP/AVIF usage) deliberately discards information the eye is least likely to notice. It is the reason a 5 MB phone photo can become a 200 KB email attachment. Once data is thrown away it is gone forever — this is why repeated “save as JPEG at 80%” produces the classic blurry, blocky look.
What JPEG actually does to an image
JPEG splits the image into 8×8 pixel blocks and transforms each block with the Discrete Cosine Transform (DCT). The result is a set of frequency coefficients: big smooth changes (low frequencies) and tiny detail (high frequencies).
The quality slider controls a quantization table that rounds or zeros out the high-frequency coefficients first. At 90–100 you keep almost everything; at 60 you are aggressively discarding fine texture and subtle gradients. The 8×8 grid is why you see “blocking” artifacts in heavily compressed JPEGs — the blocks become visible when the high-frequency detail that hid the seams is gone.
Chrominance (color) is also subsampled more aggressively than luminance (brightness) because human vision is far more sensitive to brightness edges than to color detail. That’s why skin tones and skies survive better than sharp colored text.
PNG: filters + DEFLATE, no blocks
PNG works very differently. It offers five filter types that turn neighboring pixel differences into runs of similar numbers, then feeds the result to DEFLATE (the same algorithm used in zip). It is excellent at:
- Large flat areas (logos, icons, screenshots)
- Images with only a few colors (paletted PNGs can be tiny)
- Anything that must stay pixel-perfect (line art, UI mockups, medical diagrams)
It is terrible at photographs: a 12 MP phone shot saved as PNG is often 10–30× larger than the same photo as a good JPEG.
WebP and AVIF — the modern middle
WebP (Google) and AVIF (Alliance for Open Media) combine ideas from both worlds:
- They can do lossless or lossy.
- They use more modern transforms and better entropy coding than JPEG.
- They support alpha (transparency) in lossy mode — something JPEG never could.
In practice WebP at quality 80 often matches JPEG at 90 visually while being 25–35% smaller. AVIF can go even further but is slower to encode and still has uneven browser support for some features. For the web, WebP is the safe default today; keep JPEG as the fallback.
Generational loss and the “save at 100%” myth
Every time you open a JPEG and save it again as JPEG you re-apply the lossy process on already-damaged data. The visible damage compounds. The rule is simple:
- Edit in a lossless format (TIFF, PNG, or the original RAW/HEIC) while you work.
- Export to the final delivery format once, at the quality you actually need.
- If you must re-export, start from the highest-quality master you have, not from a previously compressed JPEG.
“Save at 100%” does not mean “lossless”. It means “use the least aggressive quantization table”. There is still rounding and color subsampling; only the original source file (or a PNG export from it) is truly lossless.
Practical rules of thumb
- Photographs for email/web: JPEG or WebP, 75–85 quality, long edge capped at 1600–2048 px. You will rarely see a difference from 95, but the file will be 2–4× smaller.
- Print or critical detail: JPEG 90–95 or lossless PNG/WebP. Test on the actual printer or at 100% zoom.
- Screenshots, UI, diagrams, text: PNG or lossless WebP. Never JPEG unless you are willing to accept edge artifacts.
- Logos with transparency: PNG or WebP with alpha. Avoid JPEG entirely.
- Archival masters: Keep the original camera file (HEIC/RAW) or export a high-bit-depth TIFF. Everything else is a derived copy.
How LocalTools compression settings map to reality
The quality slider and “max long edge” control are applied before the final encode step. Lowering the long-edge cap is often more effective than dropping quality, because it reduces pixel count before any transform loss happens. When you use the per-image override you can keep one important photo at higher fidelity while the rest of a batch is aggressively shrunk.
Because the entire pipeline (decode → optional edit → resize → re-encode) happens in your browser with the same libraries a desktop app would use, the quality you see in the preview is what you will get in the downloaded file — no server-side surprises.
The same principles apply when images go into a PDF. A scanned contract or photo album becomes huge precisely because each page image is stored at print resolution without re-compression. Compressing the images first (or letting the PDF tool do it) follows exactly the same trade-offs described above.