Lossy vs Lossless Compression: What Happens to Your Image
What lossy and lossless image compression actually do, why some files shrink more than others, and how to avoid quality loss you can see.
· 6 min read
“Compress without losing quality” is a promise you see everywhere, and it is only half true. Some kinds of compression really are perfect. Others trade a little detail for a much smaller file. Knowing which one you are using helps you decide how far to push it.
Why images are so big in the first place
An uncompressed image stores a color for every pixel, usually three bytes (red, green and blue), plus a fourth for transparency. A 12-megapixel phone photo is 4000 × 3000 pixels, so in raw form it takes about 36 MB. The JPG your phone actually saves is typically 2–5 MB. That difference is compression.
Lossless compression: same pixels, smaller file
Lossless compression rewrites the data more efficiently without changing a single pixel. A simple example: instead of storing “white, white, white…” a thousand times, store “1,000 × white”. Real formats such as PNG use cleverer versions of this idea, predicting each pixel from its neighbors and storing only the difference.
Because it can only remove repetition, lossless compression works brilliantly on screenshots, logos and diagrams, and poorly on photos, where natural noise makes almost every pixel unique.
Lossless formats: PNG, lossless WebP, GIF (within its 256-color limit). Re-saving a lossless file as many times as you like never degrades it.
Lossy compression: remove what you are unlikely to notice
Lossy compression permanently discards information, chosen so that the result looks as close as possible to the original. JPG and lossy WebP rely on two facts about human vision:
- We notice changes in brightness much more than changes in color, so color detail can be stored at lower resolution.
- We notice broad shapes more than fine, high-frequency texture, so the finest detail can be simplified.
The quality setting controls how aggressively that detail is thrown away. At high settings the loss is practically invisible; at low settings it shows up as blocky areas, blurred texture and halos around sharp edges. See what JPG quality setting to use for what to look for.
Reducing colors: the third option
PNGs are often made smaller by color quantization: reducing an image with thousands or millions of colors to a palette of 256 or fewer. The file stays a normal PNG and is still compressed losslessly afterwards, but the color reduction itself is a loss.
On a logo with a handful of flat colors, nothing visible changes. On a gradient, a soft shadow or a photo, you may see banding, where a smooth transition turns into visible steps. This is why our PNG compressor offers a fully lossless setting (95% and above) as well as reduced-color settings.
Why some images shrink a lot and others barely at all
- It was already compressed. A JPG straight from a phone camera is often saved at high quality and shrinks a lot. A JPG downloaded from a website has probably been optimized already, so there is little left to remove.
- Its content. Busy textures such as grass, gravel or fabric take more data than sky or plain walls, at any quality.
- Its dimensions. Pixel count matters more than anything. Halving the width and height leaves a quarter of the pixels, and usually a far smaller file. See how big website images should be.
- The format. A photo stored as PNG can shrink enormously just by becoming a JPG or WebP. A screenshot stored as JPG may not.
Sometimes compressing produces a file that is larger than the original. When that happens and you haven’t changed the size or format, compresshive keeps your original file instead.
Generation loss: the hidden cost of lossy formats
Every time a lossy file is decoded, edited and saved again, it loses a little more. Once is fine. Ten rounds of editing and re-saving a JPG can leave visible damage. To avoid it:
- Keep an original, full-quality master copy of important images.
- Do all your editing first, then compress once as the final step.
- Compress from the original, not from an already compressed copy.
So which should you use?
Use lossy compression for photos you are publishing or sharing, at a quality where you cannot see a difference at normal viewing size. Use lossless compression for graphics, screenshots, anything with text, and master copies you will edit again. And whichever you choose, compare the result with the original before you replace it.
Try it on your own files
Free, no sign up, and you can compare the result before you download.