Skip to content

How image compression works

What compression actually does to an image, and how to use it well.

What "compressing an image" actually means

Every digital photo is, underneath, just a very large grid of numbers: one set of red, green, and blue values for every pixel. Store that grid completely uncompressed and even a modest photo runs to tens of megabytes. Compression is the general term for encoding that same grid more efficiently, so the file takes up less space on disk and less time to transfer. Every common image format (JPG, PNG, WebP) does this in its own way, and the choice of format matters just as much as any "quality" setting you adjust.

Lossy vs. lossless, in plain terms

Compression schemes split into two families. Lossless compression (PNG's approach) finds and removes pure redundancy (repeated patterns, predictable runs of similar pixels) without changing a single pixel's actual value. Decompress a lossless file and you get back exactly what went in, bit for bit. That guarantee is valuable, but it caps how much a photo can shrink, because real photos are full of subtle, non-repeating detail that lossless methods can't legally throw away.

Lossy compression (JPG and WebP's approach) takes a different deal: it's allowed to discard some visual information permanently, as long as it discards the parts human vision is least likely to notice, such as extremely fine color gradations and high-frequency detail in busy areas. Push a lossy setting far enough and the loss becomes obviously visible ("compression artifacts": blotchy color, blocky edges), but at moderate settings the difference is often invisible at normal viewing sizes, and the file can be a fraction of the lossless size.

Why the same photo can be 6MB or 400KB

This is the direct consequence of the lossy/lossless split above. A camera photo saved as PNG has to preserve every pixel exactly, so a detailed, high-resolution shot can easily land in the multi-megabyte range. Save the same photo as a JPG at a sensible quality setting and it can come down to a few hundred kilobytes, often with no difference a casual viewer would spot, because JPG is allowed to compress the parts of the image that don't carry much visual weight. This is also why converting a PNG photo to JPG or WebP is usually the single biggest lever for reducing its file size, bigger than adjusting any quality slider within PNG itself (which doesn't really have one).

There's no single "correct" compression level

How much compression is "too much" depends entirely on what the image is for, which is easy to forget when a tool just gives you one generic slider. A hero banner on a marketing page needs to look sharp at large size, so you'd bias toward quality and accept a bigger file. A photo being uploaded to a form with a strict KB ceiling has a completely different constraint: it just needs to clear that number while looking as good as possible within it, and nothing above that number is achievable anyway, no matter how much you'd prefer higher quality. Neither situation has a "right" quality percentage in the abstract. The requirement defines it.

When resizing beats compression alone

File size comes from two independent levers: how much detail is packed into each pixel (compression) and how many pixels there are in total (dimensions). If a photo is much larger than it needs to be — a 4000-pixel-wide camera shot being squeezed toward a small KB target — pushing compression quality down and down eventually produces visible artifacts long before it produces an acceptable file. Reducing the pixel dimensions first, then compressing moderately, usually gets a smaller file that also looks noticeably better, because there's simply less data that needs discarding to begin with.

Why guessing a quality slider is inefficient

A lot of compression tools hand you a slider from 0 to 100 and leave you to watch the output file size change as you drag it, re-checking after every adjustment until you land somewhere under your limit. That works, but it's trial and error toward a number you already know. If you need a file under 100KB, there's no reason to discover the right quality setting by hand each time. A tool that accepts the target size directly and searches for the highest quality that still meets it (which is the approach IMAGE SIZE PRO uses) removes that guesswork: you state the actual requirement once instead of iterating toward it.

Common mistakes

  • Re-compressing an already-compressed JPG repeatedly. Each lossy re-encode discards a little more detail on top of what the last one already removed, so quality loss compounds across generations, even at the same setting.
  • Compressing without resizing an oversized original. As above, pushing quality down on a much-larger-than-needed image usually looks worse than resizing first.
  • Using PNG for ordinary photos. PNG is the right call for screenshots, logos, and anything needing transparency. For photographic detail without transparency, a lossy format almost always gives a smaller, equally good-looking result.

See the actual numbers

Everything above is the theory. For real, measured file sizes comparing JPEG, PNG, WebP, and AVIF across several image types, including exactly when a lossy format backfires, see the image format compression benchmark.

Compression questions

Does compressing an image lose quality permanently?

If you compress with a lossy format like JPG or WebP, yes. Some detail is discarded and can't be recovered from that file. The original detail is only gone from the compressed copy, though; if you keep the original, you can always start over from it with a different setting.

Is WebP always better than JPG?

It usually compresses a bit smaller at the same visual quality, but JPG has closer to universal compatibility. If a platform accepts WebP, it's a reasonable default; if compatibility is uncertain, JPG is the safer choice.

Why does compressing a PNG do so little compared to a JPG?

PNG is a lossless format. It's designed to reproduce every pixel exactly, so its compression only removes redundancy, not visual detail. JPG and WebP are lossy: they're allowed to discard detail the eye is unlikely to miss, which is why they typically shrink much further.