Lossless compression makes an image file smaller and gives back exactly the same pixels when it is opened. Lossy compression makes it much smaller by throwing away detail you are unlikely to notice, and that detail never comes back. Use lossless for originals, screenshots, graphics and anything you will edit again; use lossy for showing images on the web and sending them. On 24 images we measured, the best lossless format saved about a third of a PNG's size, while lossy formats cut it by 87% to 96%.
What is the difference between lossy and lossless compression?
Both shrink a file by describing the image more cleverly. The difference is what you get back.
- Lossless finds patterns and repetition and writes them down more briefly, the way a ZIP file does. Decode it and you have every pixel exactly as it was. The PNG specification (W3C, third edition, June 24, 2025) puts it as a design goal: "filtering and compression should preserve all information."
- Lossy first decides which detail matters least to the eye (fine texture, small shifts in color) and discards or simplifies it, then packs what is left. The image you get back is close to the original, not identical, and a smaller file means more was discarded.
So the question is never "which is better" but "do you need the exact pixels back?"
Which image formats are lossy and which are lossless?
This is how MDN's image format guide (last modified Nov 5, 2026) lists them:
| Format | Compression |
|---|---|
| JPEG | Lossy |
| PNG | Lossless |
| GIF | Lossless (but limited to a palette of colors) |
| WebP | Lossy or lossless |
| AVIF | Lossy or lossless |
| JPEG XL | Lossy or lossless |
| TIFF | Usually uncompressed or lossless; lossy JPEG inside is possible |
The newer formats do both, so the extension alone does not tell you which kind of file you have. A .webp from a website is almost always lossy; a .webp that came out of a lossless setting is not.
How much smaller is lossy than lossless?
We measured it on Nov 25, 2026. We took 24 public images from the Heart Photos wall's Made by AI tag whose originals are PNG files: landscapes, interiors, game screenshots and a few flat graphics, 1,026 to 2,552 pixels wide, about 1.5 megapixels in the middle. Because the originals are PNG, nothing had been thrown away yet, so they are a fair starting point.
We re-saved each as PNG with Pillow 12.1.1 at its most thorough setting as the baseline, then encoded it seven ways: lossless WebP and lossy WebP with Google's cwebp 1.6.0, lossless and lossy JPEG XL with cjxl 0.12.0, JPEG and AVIF with Pillow. Then we decoded every file and compared it with the original pixels, using PSNR (peak signal to noise ratio, in decibels: higher is closer, and identical images have no PSNR at all because there is no error).
| Format and setting | Kind | Median file | Median size vs PNG | All 24 together | Median PSNR |
|---|---|---|---|---|---|
| PNG | Lossless | 2,078 KB | 100% | 59.2 MB | identical |
WebP, -lossless |
Lossless | 1,588 KB | 74% | 42.3 MB | identical |
JPEG XL, -d 0 |
Lossless | 1,442 KB | 66% | 38.1 MB | identical |
JPEG XL, -d 1 (its default) |
Lossy | 247 KB | 12% | 7.8 MB | 40.6 dB |
| JPEG, quality 85 | Lossy | 262 KB | 13% | 8.5 MB | 37.6 dB |
| WebP, quality 75 (its default) | Lossy | 131 KB | 6.3% | 4.5 MB | 36.1 dB |
| AVIF, quality 50 | Lossy | 92 KB | 3.8% | 3.1 MB | 35.5 dB |
What that shows:
- Lossless really is lossless. All three lossless formats gave back every one of the 24 images pixel for pixel; we checked each decoded file against the original.
- Lossless saves a little. WebP came in 26% under PNG by median, which is exactly the figure on Google's WebP page ("WebP lossless images are 26% smaller in size compared to PNGs"). Lossless JPEG XL did better still, a third under PNG, and was the smaller of the two on all 24.
- Lossy saves a lot. Even the most careful lossy file here was about an eighth of the PNG; AVIF was about a twenty-sixth.
- Smaller costs some fidelity. The PSNR column falls as the files shrink. JPEG XL at its default came out both smaller and closer to the original than JPEG at quality 85 on 16 of the 24 images.
- The content matters more than the format. AVIF's file ranged from 0.6% of the PNG (a purple graphic on a black background) to 9.5% (a busy game screenshot full of small text and icons).
These are one wall's images, most of them made by AI, and one setting per encoder, not a scientific test set. The direction holds; your exact numbers will differ. These lossy settings also do not all aim at the same quality, so read the sizes together with the PSNR, not on their own.
Is lossy compression bad?
No. It is the reason the web loads quickly: a page of 92 KB AVIFs arrives far sooner than a page of 2 MB PNGs, and at a sensible setting the difference is hard to spot at normal viewing size. What lossy compression is bad for is repeated editing: every save of a lossy file compresses it again and drops a bit more. We measured that in does saving a JPEG multiple times reduce quality.
The other trap is converting a lossy file to a lossless format. A JPEG saved as PNG keeps exactly what the JPEG had, flaws included, in a far bigger file. Nothing comes back.
When should you use lossless, and when lossy?
| If you are | Use |
|---|---|
| Keeping an original you may need again | Lossless, or the original file as it came |
| Saving a screenshot, logo, chart or anything with text | Lossless (PNG, lossless WebP or lossless JPEG XL) |
| Editing an image over several sessions | Lossless while you work, lossy only at the end |
| Showing photos on a website | Lossy AVIF or WebP, sized to the screen |
| Sending photos to friends | Lossy JPEG at quality 85 to 90 is the safe choice |
| Archiving JPEGs you already have | JPEG XL's lossless recompression, which gives the same JPEG back |
For choosing between the modern formats, see AVIF vs JPEG XL vs WebP; for the lossless pair, PNG vs WebP; and for picking a lossy setting, what JPEG quality should I use.
Frequently asked questions
Is PNG lossless?
Yes, always. The PNG specification defines it as lossless, and our 24 images came back from PNG pixel for pixel. A PNG can still look poor if it was made from a lossy file or reduced to fewer colors before it was saved.
Is JPEG always lossy?
In practice, yes. Every JPEG you meet from a camera, phone or website is lossy, even at quality 100, which discards less but still discards something.
What does "visually lossless" mean?
It means lossy, but tuned so that most people cannot see the difference at normal viewing. JPEG XL's own cjxl help says it plainly: distance 0.0 is "mathematically lossless" and 1.0 is "visually lossless", the default for most input. Our -d 1 files were 12% of the PNG and not identical to it.
Does zipping an image make it smaller?
Barely, for a JPEG, PNG, WebP or AVIF, because they are already compressed and ZIP is lossless too: there is little repetition left to find. We ran our test files through Deflate, the method ZIP uses, at its strongest setting: the JPEGs shrank by 0.8% in total, the PNGs by 0.3%, and the AVIFs grew slightly. It does no harm, but it will not shrink a photo the way a lossy format does.
Is lossless WebP better than PNG?
For size, usually: it was smaller on all 24 of our images, with exactly the same pixels. PNG still opens in more apps, so it is the safer file to send. PNG vs WebP goes into it.
Can I turn a lossy image back into a lossless one?
No. You can save it in a lossless format from then on, which stops further loss, but the detail the lossy compression threw away is gone for good. Keep originals if you might need them.
What Heart Photos does
Heart Photos uses both kinds, each for its own job. When you upload a PNG, its original is stored as lossless JPEG XL or lossless WebP, whichever is smaller, and only once the server has decoded it back and found the very same pixels; downloading it gives you a PNG of those exact pixels. A JPEG original is repacked as lossless JPEG XL and handed back as the very same JPEG, byte for byte. A lossy WebP is kept as it came. What visitors see is lossy AVIF at quality 50, made from that original in the sizes each screen needs, which is why the wall stays quick.
So your original is never compressed lossily by us, and the copies people browse are. To try it, Open Heart Photos and upload a PNG or a JPEG.