How to compress an image for the web

Compression advice usually arrives as a number — "aim for 200 KB" — that was measured on someone else's photo. The method below is more useful: pick the format by what the image contains, set quality by looking at the result, and verify the file rather than trusting a guideline.

First, pick the right format

The format does more for file size than any slider. A photograph saved as PNG can be ten times larger than the same photograph saved as JPEG, because PNG stores every pixel exactly and photographs contain far more distinct pixels than flat graphics.

Second, set quality by looking, not by guessing

The quality slider trades detail for bytes. Rather than picking a value from a blog post, view the image at the size it will actually be displayed. A photo shown at 800 pixels wide on a phone can lose a great deal of detail that nobody will ever see, while the same file viewed at 100% on a desktop monitor looks obviously damaged.

  1. Open the compressor for your chosen format and drop the image.
  2. Start high — near the top of the range — and note the encoded size shown in the tool.
  3. Lower the quality in steps until you can just see a difference at display size, then step back up one.
  4. Download, and compare the exported file with the original using Image Compare if you want to see exactly which pixels changed.

That last step matters because compression artefacts are not distributed evenly. Smooth skies break into banding, sharp text develops halos, and skin can turn blotchy long before the rest of the image looks wrong. Comparing the two files shows you where the damage is; a single global quality number does not.

Third, resize before you compress

Sending a 6000-pixel-wide photograph to a page that displays it at 800 pixels wastes bytes on detail that is thrown away by the browser anyway. Resize first with Resize, then compress the smaller image. The order matters: resizing after compression adds a second generation of loss, and shrinking first makes every later decision cheaper.

A sensible sequence for a photo destined for a web page is: crop to the composition you want, resize to the largest size the layout will request, then compress at the highest quality that still meets your page-weight budget. If the image will be shown at several sizes, produce a separate file for each rather than one oversized file for all of them.

What compression cannot do

Re-encoding is lossy in one direction: it removes information and cannot put it back. Saving an already-compressed JPEG a second time adds artefacts on top of the first set, which is why keeping the original is the one habit worth insisting on. If you need to edit a compressed image, start from the original file rather than the compressed copy.

Compression also cannot fix an image that is the wrong size, the wrong format, or the wrong crop. Those are composition decisions, and they belong before the quality slider.

Checking the result properly

Two things are worth checking before publishing. The first is weight: the tool shows the encoded size, so you know what you are shipping rather than what you hoped for. The second is content: converting a PNG with transparency to JPEG silently fills the transparent area with a solid colour, and converting a screenshot to a low-quality JPEG makes text unreadable.

If the file also carries location data, remove it before publishing — the Strip Metadata tool does that locally, and Metadata Viewer shows exactly what a file would reveal.