Lossless vs Lossy Image Compression: When to Use Each
Lossless and lossy compression serve different purposes. This guide explains the trade-offs clearly so you always pick the right approach for your images.
The fundamental trade-off
Every image compression decision comes down to one question: can you afford to lose information? Lossless compression preserves every bit of the original. Lossy compression discards information that is statistically unlikely to be noticed — and in return, it can achieve dramatically smaller files.
Neither approach is universally better. The right choice depends on the image content, the intended use, and whether the file will be edited again. Understanding the difference prevents the two most common mistakes: using JPEG for images where artefacts are visible, and using PNG for photographs where file sizes are needlessly large.
How lossy compression works
JPEG — the dominant lossy format — works in the frequency domain rather than the pixel domain. It divides the image into 8×8 blocks, applies a Discrete Cosine Transform (DCT) to convert each block from pixel values to frequency components, then quantises (rounds) those frequency components to reduce precision.
The human visual system is less sensitive to high-frequency detail (sharp transitions, fine texture) than to low-frequency information (overall tone, large-scale colour). JPEG exploits this by applying heavier quantisation to high-frequency components. The result looks nearly identical to the original at moderate quality settings, but the file is 5–20× smaller.
The catch: quantisation is irreversible. Once those frequency components have been rounded down, the original values are gone. And every subsequent JPEG save applies a fresh round of quantisation — quality degrades with each generation.
How lossless compression works
Lossless formats — PNG, WebP lossless, GIF — find redundancy in the data and represent it more efficiently, but never discard information. PNG uses prediction filters followed by DEFLATE compression. WebP lossless uses a more sophisticated transform chain (colour transforms, subtract-green transform, backward references, and Huffman coding). In both cases, decompression perfectly reconstructs the original pixel values.
The trade-off: for photographic images with rich detail, there is relatively little redundancy to exploit, so lossless files remain large. A 20 MP photograph saved as a lossless PNG might be 40 MB. The same photograph saved as JPEG at 85% quality might be 4 MB with no perceptible difference to the human eye.
Image types and the right format
The decision is almost entirely driven by image content:
- Photographs and photorealistic renders: Use lossy compression (JPEG or lossy WebP). The information loss is imperceptible, and the file size savings are enormous. If you need maximum quality for professional archival, use lossless — but for web delivery, JPEG or WebP lossy is the right call.
- Screenshots and UI artwork: Use lossless (PNG or WebP lossless). These images contain hard edges, text, and areas of flat colour — exactly where JPEG artefacts are most visible. The colour values in a drop-shadow or anti-aliased letter are precisely what JPEG corrupts.
- Logos and icons: Use lossless PNG or SVG. A JPEG logo with compression artefacts around the edges looks unprofessional and will be especially obvious on high-DPI screens.
- Illustrations and cartoons: Lossless if they contain flat colours and sharp edges. Lossy can work for painted-style illustrations, but watch the edges carefully.
- Medical or scientific images: Always lossless. Lossy artefacts can obscure clinically significant detail.
The re-editing problem
If a file will be opened, modified, and saved again — potentially many times — lossy compression compounds. Each save through JPEG introduces another generation of quantisation artefacts. Start with JPEG quality 85, save again at quality 85, and the effective quality of the second file is not 85 — it is the result of two rounds of lossy compression applied to the same data.
The solution: keep master files in a lossless format (PNG, WebP lossless, or a raw format like TIFF) and export to JPEG only as a final step for web delivery. Never re-edit a JPEG and save it as JPEG again if you can avoid it.
WebP: the best of both worlds?
WebP supports both lossy and lossless compression within the same format. WebP lossy typically achieves 25–35% smaller files than JPEG at equivalent visual quality. WebP lossless typically achieves 15–25% smaller files than PNG. Browser support is now universal. For new projects, WebP is often the correct default for both use cases — with JPEG and PNG as fallbacks for older contexts.
Lossless optimisation of lossy files
One important nuance: you can apply lossless optimisation to JPEG files. This does not add new artefacts or remove existing ones — it simply rebuilds the file's internal structures (Huffman tables, metadata) more efficiently. A JPEG that has been losslessly optimised decompresses to exactly the same pixels as before, just from a smaller file. This is the only form of "lossless compression" that is valid for JPEG.
To compress your images losslessly — whether PNG, JPEG, or WebP — try compressanimage.com. It applies the right lossless optimisation strategy for each format automatically.