Lossless Compression
A compression method restoring original data bit-for-bit. Reduces file size with zero quality loss.
Lossless compression produces output that decompresses to bit-for-bit identical data. No information is lost, enabling size reduction without quality sacrifice - foundational wherever data integrity is required.
Major algorithms for images:
| Algorithm | How it works | Where it is used |
|---|---|---|
| Deflate | LZ77 sliding window combined with Huffman coding | PNG (implemented via zlib) |
| LZW | Dictionary-based: builds the dictionary dynamically and replaces repeated patterns with short codes | GIF, TIFF |
| Run-Length Encoding | Simplest technique - "value x count" for consecutive identical values | BMP |
| Entropy coding | Variable-length codes assigned by frequency. Arithmetic coding achieves near-theoretical limits | JPEG 2000, AVIF lossless |
Ratios depend on content. Uniform areas and patterns (screenshots, logos) achieve 50-80% reduction; complex photographs only 10-30%. Significantly lower than lossy compression.
Essential for medical imaging (DICOM), scientific data, legal evidence, and print masters. In editing workflows, lossless intermediates prevent generation loss from repeated saves.
You can compare how each approach affects file size with the image compression tool, which runs entirely in your browser and offers lossless PNG output alongside lossy JPG and WebP.