Glossary Term
Lossless Compression
Lossless compression reduces file size without discarding any image data — the decompressed image is identical to the original, pixel for pixel.
How lossless compression works
Lossless compression finds and eliminates redundancy in image data without removing any information. When the compressed file is decompressed, every original pixel value is restored exactly.
The core techniques vary by format, but the principle is consistent. Consider a screenshot with a solid blue toolbar spanning 1,200 pixels. Instead of storing 1,200 identical blue values, lossless compression records something like "1,200 repetitions of this blue." This run-length encoding is one of the simplest forms of lossless compression.
More sophisticated algorithms, like the DEFLATE algorithm used in PNG, combine multiple techniques: finding repeated patterns, building dictionaries of common sequences, and encoding frequent values with fewer bits. The result is a file that contains enough information to perfectly reconstruct the original but uses less storage than the raw pixel data.
The effectiveness of lossless compression depends heavily on image content. Screenshots with flat UI colors, solid backgrounds, and repeated patterns compress extremely well — sometimes to 10-20% of the raw size. Photographs with complex textures and subtle color variations compress poorly, often remaining at 50-70% of raw size. This is why screenshots look great as PNG while photographs are better served by lossy formats.
Lossless formats: PNG, WebP lossless, TIFF
Several image formats support lossless compression, each with different strengths.
- PNG — the most widely used lossless format for web and screen content. Supports transparency, compresses efficiently for screenshots and graphics, and is universally compatible across all platforms and browsers.
- WebP lossless — Google's format that typically produces files 20-30% smaller than PNG at identical quality. Broad browser support, though not quite as universal as PNG in desktop applications.
- TIFF — a flexible format used in publishing, scanning, and professional photography. Supports multiple compression methods including LZW lossless. Large file sizes and limited web support make it unsuitable for screen content.
- AVIF lossless — the newest option, offering competitive compression ratios. Slower encoding speed and narrower platform support limit its current practical use for lossless workflows.
For screenshot workflows, PNG remains the default choice for its combination of quality, compatibility, and reasonable file size. Capture tools that offer WebP lossless as an alternative can reduce storage requirements without any quality trade-off.
In real screenshot pipelines, lossless is usually the archive format, not always the delivery format. Teams keep the pixel-accurate master for future edits and generate smaller copies only when they know the destination can tolerate it.
Lossless vs lossy
The choice between lossless and lossy compression comes down to what matters more: perfect fidelity or minimal file size.
Lossless compression guarantees that no data is lost. This matters when the image contains text that must remain readable, when the image will be edited further (each lossy save compounds quality loss), or when the image serves as evidence or documentation where accuracy is critical.
Lossy compression discards data strategically. For photographs destined for social media or web pages, the quality difference at moderate compression is imperceptible to most viewers. The file size savings — often 80-90% compared to lossless — make lossy the practical choice for these use cases.
A common middle-ground approach is to capture and archive in lossless format, then export lossy versions for distribution. This preserves the original while optimizing delivery. Some capture and processing tools automate this pattern, saving a lossless master and generating optimized copies in one step.
Common mistakes
- Using lossless compression for photographs on the web. A lossless photograph can be five to ten times larger than a lossy version with no perceptible quality difference on screen. Reserve lossless for content where pixel accuracy matters.
- Re-saving a lossy image as lossless to "restore" quality. Saving a JPG as PNG does not recover the data already lost to JPG compression. The PNG will be larger than the JPG but no better in quality. Always start from the original source.
- Ignoring lossless options for screenshots. Screenshots with text and UI elements benefit most from lossless compression. Using lossy formats for these images risks introducing artifacts around sharp edges and making text harder to read.
- Assuming lossless means uncompressed. Lossless files are compressed — they are smaller than raw pixel data. The "lossless" label means no quality is lost, not that no compression is applied.
Common Questions
Does lossless compression reduce image quality?
No. By definition, lossless compression preserves every pixel exactly. The decompressed image is bit-for-bit identical to the original. Only the file size changes — the visual content does not.
Why are lossless files larger than lossy files?
Lossless compression must preserve all original data, which limits how much redundancy can be removed. Lossy compression achieves smaller sizes by permanently discarding data the eye is unlikely to notice, allowing much more aggressive size reduction.
Is PNG lossless?
Yes. PNG always uses lossless compression. Every pixel in a PNG file is preserved exactly as it was in the original image. This is one reason PNG is the standard format for screenshots.
Can lossless compression make files smaller than lossy?
Rarely. In most cases, lossy compression produces significantly smaller files. However, for images with large areas of identical color — like simple diagrams or UI screenshots with flat backgrounds — lossless compression can be very efficient.
When should I choose lossless over lossy compression?
Choose lossless when pixel accuracy matters: screenshots with readable text, technical diagrams, medical imaging, legal documents, or any image that may be edited further. Choose lossy when file size is the priority and minor quality loss is acceptable.
Sources
- Lossless compression — MDN Web Docs
- Image file type and format guide — MDN Web Docs