What Is Lossless Image Compression? A Plain-English Guide

Lossless image compression shrinks your files without discarding a single pixel. Learn how it works, when to use it, and why it matters for quality-critical images.

What does "lossless" actually mean?

When you compress a file, you're trying to store the same information using fewer bytes. The question is what you're willing to sacrifice to get there. Lossy compression — used by JPEG at most quality settings — permanently discards information the algorithm judges to be imperceptible. You trade a small amount of accuracy for a large reduction in file size.

Lossless compression makes no such trade. Every single bit of the original file can be perfectly reconstructed from the compressed version. Decompress a losslessly-compressed PNG and you get back exactly the same pixels, with exactly the same colour values, as the original. Not "similar". Identical.

This matters enormously in contexts where accuracy is non-negotiable: medical scans, design source files, screenshots, technical diagrams, images that will be edited and re-saved multiple times, and anything where you need the decompressed output to be bit-for-bit identical to the input.

How lossless compression finds redundancy

All lossless compression works by finding and eliminating redundancy — patterns in the data that can be represented more efficiently without losing information. Images contain a surprising amount of redundancy.

Consider a screenshot of a web page. Large areas of the background are a single solid colour. Text is rendered on white. Icons are surrounded by transparent pixels. A raw bitmap would store a separate RGB value for every single pixel, even when thousands of adjacent pixels are identical. That is extraordinarily wasteful.

Lossless algorithms exploit three main types of redundancy:

  • Spatial redundancy: Adjacent pixels are often similar or identical. Run-length encoding captures this: instead of storing the same value 500 times in a row, store the value once and the count 500.
  • Statistical redundancy: Some pixel values appear far more often than others. Huffman coding assigns shorter bit sequences to common values and longer sequences to rare ones, reducing the average bits-per-symbol.
  • Structural redundancy: Repeating patterns across the image (a tiled background, a repeating texture) can be referenced rather than repeated. The LZ77 algorithm family exploits this with a sliding-window dictionary.

PNG uses a combination of all three: a prediction filter (to reduce values to near-zero differences), followed by DEFLATE compression (which combines LZ77 and Huffman coding). WebP lossless uses a more sophisticated transform chain that typically achieves 10–30% smaller files than PNG for the same input.

Lossless compression in practice

When you drop a PNG onto an image optimiser and it comes back smaller, something specific happened. The original file may have been saved with a suboptimal DEFLATE compression level (many image editors default to level 6 out of 9). A dedicated compressor re-runs DEFLATE at the maximum level, spending more CPU time to find better matches and shorter codes — but the output is still perfectly decompressible.

Some optimisers also try alternative PNG filter strategies. PNG allows five filter types (None, Sub, Up, Average, Paeth), and the best choice varies by image content. The encoder that saved your file may have used a fixed strategy; a dedicated optimiser tests multiple strategies and keeps whichever produces the smallest result.

For JPEG files, "lossless" optimisation takes a different form: the pixel data is not touched, but the file's Huffman tables (a type of statistical dictionary) can be rebuilt more efficiently, and embedded metadata (EXIF camera data, ICC colour profiles, comments) can be stripped. The result is a smaller JPEG that decompresses to exactly the same pixels as before.

When to use lossless compression

Use lossless compression whenever:

  • The image contains text, fine lines, or hard edges (logos, screenshots, diagrams). JPEG's artefacts are visible at these edges; PNG's lossless encoding is not.
  • The image will be edited and re-saved. Every lossy save degrades quality further. Working in PNG and converting to JPEG only at export avoids this generational loss.
  • Pixel-perfect accuracy is legally or professionally required — medical imaging, archival photography, product renders that must match physical samples.
  • The image has large flat-colour areas. PNG compresses these extremely efficiently, often beating JPEG even on file size.

Use lossy compression (JPEG or lossy WebP) for natural photographs where slight inaccuracies are invisible to the human eye and file size matters more than perfect fidelity.

How much can lossless compression save?

Results vary widely by image type. A screenshot of a code editor might compress from 800 KB to 120 KB — an 85% reduction — because it is dominated by flat background colours and a limited palette. A photograph saved as PNG will compress far less, because natural images are information-dense with little spatial redundancy. For photographs, lossless WebP typically beats PNG by 15–25%, and both are larger than an equivalent-quality JPEG.

The practical takeaway: choose your format based on image type first, then apply lossless optimisation to get the best possible size for that format.

Try it yourself

You can compress PNG, JPEG, and WebP images without losing a single pixel of quality using the free tool at compressanimage.com. Drop your files in, and the tool applies lossless optimisation — deflate maximisation for PNG, Huffman table rebuilding for JPEG, lossless re-encode for WebP — entirely in your browser. Nothing is uploaded to a server.

lossless compressionimage compressionPNGWebP

Ready to compress your images without losing quality?

Try the free tool →