Fix Compression Artifacts: How to Compress Images Without Losing Quality
You set quality to 80, export, and the file is byte-identical to quality 20. On ImageMagick 7.1.2-27 the AVIF delegate ignores the quality argument entirely — quality 20, 50, 80, 95 all produce the same bytes — so no slider will fix the banding you are staring at. The tool is not broken; the encoder is not listening. How to compress an image without losing quality starts with naming the artifact, not dragging the slider.
Step 1 — Name the artifact before touching quality
Every bad compression looks wrong in a specific way, and each way points at a different cause:
| Artifact | Looks like | Real cause |
|---|---|---|
| Banding | Sky or backdrop splits into stripes | Too few distinct values; 8-bit only has 256 levels |
| Blocking | 8×8 squares in dark areas | Quantization too aggressive (usually < q55) |
| Ringing | Ghost echoes beside text/edges | Frequency codec on hard transitions |
| Color smearing | Fringing on saturated text | Chroma subsampling, not quality |
Step 2 — Stop comparing one quality number across formats
Quality 80 is not the same in AVIF, WebP and JPEG. At quality=80 for every format, AVIF files came out larger than JPEGs, because AVIF 80 is far higher quality than JPEG 80. Compare at equal measured quality, not equal setting:
| Format | Web quality range | Saving vs JPEG (same score) |
|---|---|---|
| AVIF | 55–65 | 62–71% smaller |
| WebP | 75–80 | 30–44% smaller |
| JPEG (mozjpeg) | 75–85 | baseline |
| PNG | lossless | use for graphics, not photos |
Step 3 — Encode once, from the original
Never re-compress a compressed file. Decode once, encode once, and set chroma explicitly — sharp defaults to 4:4:4, which bloats photos:
import sharp from "sharp"; await sharp("source.png") .resize({ width: 1200, withoutEnlargement: true }) .avif({ quality: 58, // AVIF scale, not JPEG effort: 4, // 0–9, higher = slower/smaller chromaSubsampling: "4:2:0" // photos; use 4:4:4 for text }) .toFile("output.avif"); Step 4 — Pick the format by content, not by habit
AVIF is smallest for photos but slow to encode; WebP is the safe modern default; JPEG is the universal fallback; PNG is for screenshots and transparency. The browser-side equivalent is a single canvas pass:
async function compress(file, quality = 0.8) { const bitmap = await createImageBitmap(file); const canvas = document.createElement("canvas"); canvas.width = bitmap.width; canvas.height = bitmap.height; canvas.getContext("2d").drawImage(bitmap, 0, 0); const blob = await new Promise(res => canvas.toBlob(res, "image/webp", quality) ); return blob; // quality is format-specific, not comparable } Step 5 — Verify at real viewing size
Zooming to 200% lies. Score the result against a lossless PNG (SSIMULACRA2 80 ≈ "not noticeable side by side"), or load original and compressed side by side at 1:1. If banding appears, raise quality for that image only — gradients need ~85 where textured photos are fine at 75. The batch Image Compressor & Converter tool does AVIF/WebP/JPEG in bulk with a before/after compare, so you can test settings per image. For raster export at fixed sizes, the Avatar & Icon Maker renders the same design at 32–1024 px, and the Brand Asset Generator exports PNG badges with the same quality rules.
Artifacts are not a quality problem you can brute-force; they are a diagnosis. The unique angle: the quality number that fixes banding in one format is the number that breaks it in another, so the only safe move is to compress once from the original and compare at equal measured quality — not equal setting.
Author's note: All tool links are self-hosted, pure client-side, no account, no ads, no tracking.