By the ImageOpti team ·
Lossy vs Lossless Compression Explained
Lossy compression discards detail to make files much smaller, lossless keeps every pixel. Learn how each works, which formats use which, and when to choose them.
Lossless compression makes an image file smaller without changing a single pixel, so you can get the exact original back. Lossy compression makes files much smaller by permanently throwing away detail that people are unlikely to notice. Photos usually suit lossy compression, while logos, screenshots and files you plan to edit again usually suit lossless.
Understanding the difference helps you avoid two common problems: files that are far bigger than they need to be, and images that slowly get worse every time they are saved.
Why images need compression at all
A picture on a screen is a grid of pixels, and each pixel stores a colour. A common way to store colour uses three values, one each for red, green and blue, at one byte each. So each pixel takes 3 bytes.
Take a phone photo of 4000 by 3000 pixels:
- 4000 x 3000 = 12,000,000 pixels.
- 12,000,000 x 3 bytes = 36,000,000 bytes, or about 36 MB.
Yet a typical phone photo saved as a JPG is a few megabytes. Compression is what closes that gap. Without it, sharing photos online, emailing them or storing thousands of them on a phone would be impractical.
Lossless compression: smaller, with nothing lost
Lossless compression looks for repetition and predictable patterns in the data and stores them more efficiently. When the file is opened, the pattern is expanded again and every pixel returns exactly as it was.
A simple analogy is shorthand. Instead of writing "white, white, white, white, white, white", you write "6 white". Nobody loses any information, and the note is shorter.
This works especially well on images with large flat areas or repeated patterns: screenshots, diagrams, logos and flat illustrations. It works less well on photographs, because real-world photos contain subtle variation almost everywhere, so there are fewer clean repetitions to exploit.
The most familiar lossless image format is PNG. Others include GIF (limited to 256 colours), and WebP in its lossless mode. Zip files use the same general idea for any data.
Lossy compression: much smaller, with a trade-off
Lossy compression goes further by deciding that some information does not matter very much, and discarding it. It relies on how human vision works. We are good at noticing changes in brightness and edges, and less good at noticing tiny differences in colour, or fine texture in busy areas.
So a lossy encoder might:
- Store colour at lower detail than brightness.
- Blur very fine texture that would be invisible at normal viewing size.
- Simplify smooth gradients into broader steps.
The result is a file that can be a small fraction of the lossless version, while looking very similar. The key phrase is "looking similar". Compare closely and you can find differences, and those differences are permanent. The discarded information cannot be recovered from the compressed file.
Common lossy formats are JPG and WebP in its lossy mode. Newer formats such as AVIF also offer lossy compression. See AVIF vs WebP vs JPEG for how they compare.
Side by side
| Lossless | Lossy | |
|---|---|---|
| What happens to pixels | Every pixel is restorable | Some detail is permanently discarded |
| File size | Smaller than raw, but often large for photos | Usually much smaller |
| Quality over repeated saves | Does not degrade | Degrades each time |
| Best for | Logos, screenshots, text, graphics, master files | Photographs for viewing |
| Common formats | PNG, lossless WebP, GIF | JPG, lossy WebP, AVIF |
| Quality setting | Usually none | Yes, a slider |
What the quality setting does
Lossy tools give you a quality number, usually from 0 to 100. A higher number discards less and gives a larger file. A lower number discards more and gives a smaller one.
The relationship is not a straight line. Large savings come early. Moving from 100 down to around 80 often shrinks the file dramatically with almost no visible change, because the first details removed are the ones you cannot see. Further reductions save less each time and begin to show. Below roughly 50, common problems include blocky patches in smooth areas such as skies, fuzzy halos around text and edges, and banding in gradients.
The right setting depends on the picture. A plain studio shot can tolerate a lower setting than a detailed landscape, and a large hero image needs more care than a tiny thumbnail. The Optimize tool starts at quality 75, and its before and after comparison lets you check for yourself instead of guessing. It accepts JPEG, PNG and WebP up to 50 MB, and runs in your browser so files are not uploaded.
Generation loss: why repeated saving hurts
A lossless file can be opened and saved a hundred times with identical results. A lossy file cannot. Every time you open a JPG, edit it and save it again as a JPG, the encoder runs again and discards a bit more. Individually the changes are small, but they accumulate, and artifacts such as blockiness become visible. This is called generation loss.
Practical rules:
- Keep an original, and always export new versions from it.
- Make all your edits first, then export to a lossy format once.
- If you need to edit repeatedly, work in a lossless format such as PNG, and export a JPG at the end.
- Do not run the same image through compression tools over and over expecting it to keep shrinking. It will not, and you will only add damage.
A common myth: converting to PNG improves a JPG
People sometimes convert a JPG to PNG believing it restores quality. It does not. The PNG preserves exactly what the JPG contained, including the artifacts, and stores it without further loss. The file gets bigger, because it is now lossless, but the image does not get better. For a worked comparison of the formats, see PNG vs JPG vs WebP.
The reverse can be sensible. Converting a photo stored as PNG to JPG or WebP can reduce its size a lot, and since photos tolerate lossy compression well, the visual cost is usually small. The Convert tool does this in your browser. Note that JPG has no transparency, so transparent areas become white in the output.
Choosing between them: a practical guide
Use lossy when:
- The image is a photograph.
- It is going on a web page, social post or email.
- A smaller file matters more than perfect fidelity.
Use lossless when:
- The image is a logo, icon, diagram or screenshot with text.
- It has sharp edges and flat colours.
- It is a master file you will edit again.
- Exactness matters, as in some technical, medical or archival uses.
Often the best workflow uses both: keep a lossless or original master, and publish a lossy copy sized for its purpose.
Size before compression
Before reaching for either kind of compression, consider reducing the pixel count. If an image is displayed at 1000 pixels wide, a 4000 pixel original wastes almost everything. The example from earlier makes this plain: a 4000 by 3000 photo has 12,000,000 pixels, while the same photo at 1000 by 750 has 750,000, only 6.25 percent as many. No compression setting can match that saving without damaging the image.
So resize first using the Resize tool, then choose the format and compression level. The article on reducing image file size without losing quality covers the full order of steps.
Frequently asked questions
Is JPG lossy or lossless?
JPG is lossy. Every save discards some detail, which is why quality settings exist.
Is PNG lossless?
Yes. PNG stores the exact pixels. Some tools reduce the number of colours before saving a PNG, which is a lossy step applied before the lossless storage. The Optimize tool does this for PNG at lower quality settings, while at quality 95 and above no colours are removed.
Is WebP lossy or lossless?
It can be either. The format has a lossy mode for photos and a lossless mode for graphics.
Can I get the lost quality back from a lossy file?
No. Once the detail is discarded, it is gone. Always keep your original.
Which compression is better?
Neither is better in general. Lossy gives smaller files, lossless gives exactness. The right choice depends on the image and its purpose.
Will I notice the difference between lossy and lossless?
At moderate settings and normal viewing size, often not for photos. On text and sharp-edged graphics, lossy artifacts are easier to see.
Related guides
For choosing between formats, see the image conversion guide.