Lossless vs lossy compression for images explained
Every common image format compresses its data, so a smaller file does not by itself tell you anything about quality. What matters is whether the compression can be undone exactly. This guide starts with measurements from a small test, then explains what is going on and how to choose.
The numbers first
I generated three 1200 x 800 pixel test images with Pillow 11.3 and saved each in several ways. The images are computer-made, not camera photos, so this is an illustration, not a benchmark.
| Image | PNG (lossless) | JPG, quality 90 | WebP, quality 90 | WebP, lossless |
|---|---|---|---|---|
| Photo-like (smooth gradients and noise) | 917 KB | 109 KB | 56 KB | 781 KB |
| Screenshot-style (text rows on grey) | 27.3 KB | 87.4 KB | 14.8 KB | 2.5 KB |
Two things stand out. On the photo-like image, the lossy files were roughly an eighth to a sixteenth of the lossless ones. On the screenshot-style image, the lossy JPG was about three times bigger than the lossless PNG. Lossy is not automatically smaller; it is smaller when the picture has the kind of detail it can safely discard.
I also confirmed one more thing: after saving the photo-like image as PNG and reading it back, every pixel was identical to the original. That is what lossless means.
What lossless compression does
Lossless compression finds patterns and stores them more efficiently, in a way that can be reversed to give back exactly the same pixel values. PNG uses deflate compression with a sliding window, and the specification states plainly that all PNG filters are strictly lossless. The Library of Congress describes PNG compression in the same terms. Lossless WebP does something similar, predicting each pixel from its neighbours and storing the difference, with a palette step when an image has fewer than 256 colours.
The cost is limited savings on busy images. Photographs contain noise and gradual tone changes with few exact repeats, so there is little to squeeze. Large flat areas, repeated shapes and a small number of colours compress very well, which explains the screenshot result above.
What lossy compression does
Lossy compression deliberately discards information judged unlikely to be noticed. The JPEG committee describes the core of JPEG 1 as a Huffman-coded DCT-based lossy image format. Google's documentation says lossy WebP likewise applies a DCT to the prediction residual and then quantization, and that quantization is the only lossy step. Quantization is the crucial one: it rounds fine detail into coarser steps, and that detail is gone once the file is saved.
You control how much is lost with a quality setting. Lower numbers give smaller files and more visible damage. Because the scales differ between programs, "quality 80" in one tool does not match "quality 80" in another.
What lossy damage looks like
MDN gives the practical warning: applying lossy compression to content requiring sharpness, like diagrams or charts, can produce unsatisfactory results, with blurring and coloured fringes around text and sharp edges being very visible. On photographs the same process is far less noticeable, since natural textures hide the changes.
Does repeated saving make it worse?
It can. Each time a lossy image is opened, edited and saved as a lossy file again, another round of compression is applied. In my test, I saved the photo-like image as JPG at quality 75 and then re-saved it nine more times at the same setting with no edits. The average difference from the original was 1.54 (on a 0 to 255 scale, per colour channel) after one save and the same after ten, so plain re-saving did very little extra harm. Editing between saves, resizing, or switching between different lossy formats is where damage accumulates. The safe habit is simple: keep an original or lossless master and export lossy copies from it, never from another lossy copy.
Does converting lossy to lossless help?
No. Saving a JPG as PNG gives a lossless container around a picture that has already lost detail. The file usually gets larger and the quality stays the same. It does stop further loss, and it makes sense if you plan to edit the image several times. For the details, see how to convert JPG to PNG.
Which should you choose?
web.dev's guidance is to use lossless formats such as PNG or lossless WebP for fine detail, and lossy formats for photos, testing quality levels to balance quality and size.
- Photographs for sharing or the web: lossy, at a quality you have checked by eye.
- Screenshots, text, logos, diagrams: lossless.
- Anything you will edit again: lossless master, lossy exports.
- Archive copies: lossless, or the original file untouched.
- Needs transparency: PNG or WebP. JPG cannot.
Doing it with ConvertMango
- PNG to JPG makes a lossy copy of a PNG. JPG output requests a fixed browser quality of 0.92, and transparent areas are filled white.
- JPG to PNG and WebP to PNG produce lossless PNG. This does not restore anything already lost.
- PNG to WebP and JPG to WebP export WebP where your browser supports it, and lossy WebP also uses a browser quality setting.
All run in your browser, so file contents are not uploaded to ConvertMango's conversion service. They handle one image at a time, up to 50 MB and 40 megapixels. For a format-by-format look, read PNG vs JPG and what is JPEG.
Convert it now
Use our PNG to JPG tool. It runs in your browser, so the contents of your file are not uploaded to our conversion service. You get five free conversions a day without signing up. The allowance resets at 00:00 UTC.
Frequently asked questions
Does lossless mean the file is not compressed?
No. Lossless files are compressed too, but in a way that can be reversed exactly. PNG, for example, uses deflate compression, the same family used in zip files.
Can I turn a lossy image back into a lossless one?
You can save it in a lossless format such as PNG, but the detail already discarded does not come back. The file will just stop losing more.
Does every save of a JPG make it worse?
Each time you decode a JPG and save it as a lossy file again, you add another round of compression. Re-saving without editing at the same settings can change very little, but editing and re-saving repeatedly is best avoided.
Related tools
More guides
Sources
- Library of Congress, 'PNG (Portable Network Graphics), Version 1.2', https://www.loc.gov/preservation/digital/formats/fdd/fdd000153.shtml
- IETF, 'RFC 2083: PNG (Portable Network Graphics) Specification Version 1.0', https://www.rfc-editor.org/rfc/rfc2083.html
- JPEG committee, 'JPEG 1 (ISO/IEC 10918)', https://jpeg.org/jpeg/index.html
- MDN Web Docs, 'Image file type and format guide', https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types
- Google, 'WebP Compression Techniques', https://developers.google.com/speed/webp/docs/compression
- web.dev, 'Choose the right image format', https://web.dev/articles/choose-the-right-image-format
