What is image compression?

Compression makes an image file smaller by removing information — either information the file was storing inefficiently, or detail your eye was never going to notice.

The short version

What it does
Reduces the number of bytes needed to store a picture.
Two kinds
Lossless keeps every pixel exactly. Lossy discards detail permanently.
Typical lossy saving
60–90% off a camera photograph with no difference visible at normal viewing size.
Typical lossless saving
0–60%, depending entirely on how repetitive the image is.
Biggest lever
Pixel dimensions. Halving width and height removes three quarters of the data before any encoder runs.
Cannot be undone
Lossy compression is one-way. Keep your original.

Understanding compression

Why an image can be made smaller at all

An uncompressed photograph is a straightforward list: for every pixel, how much red, green and blue it contains. A 12-megapixel photo is twelve million pixels at three bytes each, which is about 36 MB before anything clever happens.

Almost none of that data is surprising. The sky in the top-left corner is very close to the sky next to it. A wall is thousands of nearly identical pixels in a row. Compression exists because a description of an image is almost always shorter than a list of its pixels — and because a great deal of what is in that list is below the threshold at which human vision notices anything.

Every compression format is a different answer to two questions: which patterns are worth describing rather than listing, and how much of the detail can be dropped before someone complains.

Lossless: rearranging, never removing

Lossless compression finds redundancy and encodes it more efficiently. If a row contains four hundred identical pixels, it records "this colour, four hundred times" instead of four hundred copies. Decode the file and you get back precisely what went in, byte for byte.

PNG works this way, and so does a ZIP archive. The guarantee is absolute, which is why it is the right choice for screenshots, diagrams, logos and anything you will edit again.

The limitation is equally absolute. An algorithm forbidden from discarding anything can only exploit redundancy that is genuinely present. A photograph, full of sensor noise where almost every pixel differs slightly from its neighbour, offers very little — which is why photographs saved as PNG are enormous.

Lossy: discarding what you will not miss

Lossy compression throws information away on purpose, choosing what to lose based on how human vision works.

Two facts drive nearly all of it. First, we notice changes in brightness far more than changes in colour, so colour can be stored at lower resolution. Second, we notice broad shapes far more than fine texture, so fine texture can be described crudely or dropped entirely.

JPEG, lossy WebP and AVIF all exploit both. The result is a file five to ten times smaller than a lossless one, and — at sensible settings — an image you cannot tell apart from the original at the size it is actually displayed.

The cost is that the discarded detail is gone. There is no setting that recovers it, and no tool that can reconstruct it later.

The lever most people forget

Before any encoder setting, there is resolution. File size scales roughly with pixel count, so halving both the width and the height leaves a quarter of the pixels and close to a quarter of the file.

A 4000-pixel-wide photograph displayed in an 800-pixel column is carrying twenty-five times the data it can possibly show. No quality slider recovers that waste — only resizing does. Reduce the dimensions to what will actually be displayed first, and then think about quality.

What compression cannot do

It cannot add detail. Enlarging a small image produces a soft large image, because the information was never recorded.

It cannot reverse itself. A JPEG re-saved as PNG is a lossless copy of a lossy image, not a restored original.

And it cannot fix a file that was the wrong format to begin with. A screenshot saved as JPEG has haloes around every letter, and compressing it harder only deepens them. The fix is to change format, not settings.

Compress something and watch the numbers

Everything below runs in your browser, so you can test any of this on your own files without uploading them.

  • Compress JPEG

    Shrink JPG and JPEG photographs with a quality slider or an exact target size.

    Open the tool
  • Compress PNG

    Lossless by default, with transparency carried through untouched.

    Open the tool
  • Lossless compressor

    Zero quality loss, every pixel preserved exactly. Honest about how modest the saving is.

    Open the tool

Questions

Frequently asked questions

Every answer below is present in the page source, expanded, so it can be read without opening anything.

Does compressing an image always reduce its quality?

No. Lossless compression — PNG, lossless WebP — leaves every pixel value untouched, so there is no quality change of any kind. Lossy compression does reduce quality by definition, but at sensible settings the reduction is below the threshold at which anyone notices it at normal viewing size.

How much smaller can an image get?

For an unoptimised camera photograph, 80–95% smaller is routine once you resize to what will actually be displayed and compress at a sensible quality. For an image that has already been through a good encoder once, there is often only 10–25% left, and pushing further costs visible quality.

Which is better, lossy or lossless?

Neither — they suit different content. Photographs belong in a lossy format because the noise and gradient that make them photographic also make them compress beautifully. Screenshots, logos, line art and anything with text belong in a lossless format, because lossy encoders produce visible haloes around hard edges.

Can I compress an image more than once?

You can, but with lossy formats you should not. Each save re-quantises data that has already been quantised, treating the previous pass's errors as real detail and adding new errors on top. That is generation loss, and it only accumulates. Always compress from the highest-quality original you have.

Does compression change the pixel dimensions?

Not by itself. Compression changes how the pixels are stored, not how many there are. Resizing is a separate operation — and usually a more effective one — which is why most tools, including the ones here, offer both.

Is compressing images online safe?

It depends entirely on whether the tool uploads your file. Most do, which means a copy of your photograph exists on infrastructure you cannot inspect. The tools on this site do the work in your browser, so no file is transmitted at all — you can disconnect from the network after the page loads and they still work.

From the blog

Related reading

Longer, more practical guides from the blog.

  • Image Compression

    JPEG Quality Settings Explained: What the Number Actually Means

    Quality 80 is not 80% of anything. It is an index into a quantisation table. Measured on one photograph: dropping from 100 to 90 removes 77% of the file and 4.2 dB of fidelity; dropping from 40 to 30 removes 17% and costs almost as much.

    8 min read

  • Practical Guides

    How to Compress Images for a Website Without Wrecking Them

    Resize before you compress. Measured on one photograph: half the width at quality 80 produced a 16.4 KB file, while full width at quality 40 produced 20.6 KB and looked far worse. The order of operations matters more than the settings.

    8 min read

  • Image Formats

    PNG vs JPEG: When to Use Each, With the File Sizes to Prove It

    PNG stored the same photograph in 1274.1 KB where JPEG needed 67.5 KB — nineteen times larger. On a flat graphic PNG won. On a smooth gradient PNG lost to JPEG by a factor of two, which surprises most people.

    9 min read