How JPEG compression works
JPEG uses a lossy compression algorithm designed for photographs. The process has three stages: colour space conversion (RGB → YCbCr, which separates brightness from colour), a Discrete Cosine Transform (DCT) that converts 8×8 pixel blocks into frequency components, and quantisation — where high-frequency details are discarded at a rate controlled by the quality setting.
The quality slider maps to a quantisation table multiplier. At quality 100, almost no data is discarded — the file is nearly lossless (and nearly as large as an uncompressed bitmap). At quality 50, coarse frequency data is retained but fine detail is aggressively rounded. Below quality 40, visible artefacts appear: blocky 8×8 "mosquito noise" around sharp edges, posterisation in smooth gradients.
Why 80% is usually enough
Human vision is more sensitive to luminance (brightness) changes than to chrominance (colour) changes. JPEG exploits this by subsampling the colour channels at 4:2:0 by default — storing one colour sample per 4 brightness samples. At quality 80%, the luminance quantisation is mild and the chroma subsampling is already applied regardless. The result is typically indistinguishable from the original at normal viewing distances on screen.
For print output, go to 90–95%. For hero images examined closely on Retina displays, 85%. For thumbnails and preview images, 70–75% is hard to distinguish and saves substantial bandwidth.
WebP vs JPEG
WebP (developed by Google, published 2010) uses a more modern algorithm — VP8 video codec intra-frame encoding with lossless fallback. At the same visual quality, WebP is typically 25–34% smaller than JPEG for photos and 26% smaller than PNG for graphics. All modern browsers and iOS (since 14) support WebP.
The tradeoff: older apps (some email clients, legacy CMS systems) may not display WebP. JPEG has 100% compatibility including decade-old Android apps and Windows XP's Photo Viewer. For web-only delivery, WebP is the better choice. For files that will be attached to emails or shared via WhatsApp, JPEG is safer.
When re-compression makes a file larger
If you open an already-compressed JPEG and re-save it at the same or higher quality setting, the file can come out larger. This happens because the Canvas API decodes the JPEG to a raw uncompressed bitmap in memory, then re-encodes it — the second encoding applies to a slightly different set of frequency components than the first, sometimes producing marginally more data. To avoid this: always start from the highest-quality source, and compress once to the target quality rather than re-compressing repeatedly.