How-to · 5 min read

How to compress an image to an exact file size

Getting under a 2 MB upload limit without dragging a quality slider back and forth, and knowing what you traded away to get there.

Almost every request to "make this smaller" is really a request to get under a specific number: 2 MB for a job application portal, 500 KB for a forum avatar, 100 KB for a page that has to load quickly. But the controls most tools give you are quality percentages, and the relationship between a quality percentage and a file size is not something anyone can predict — it depends entirely on the content of the picture. A photograph of a busy street at quality 70 might be 900 KB; a photograph of a clear sky at quality 70 might be 60 KB.

The way out is to work backwards. Instead of choosing a quality and seeing what size you get, state the size you need and let the tool search for the quality that lands under it. Compress Image does that search in your browser, re-encoding at a handful of quality levels until it finds the highest one that fits.

Step by step

How to do it

  1. Open the image in the compressor

    Go to Compress Image and drop the photo on the box. The original size is shown so you know what you are starting from.

  2. Enter the size you need to hit

    Set the target — the number the thing you are uploading to actually asks for. Leave a little headroom if the limit is a hard rejection rather than a warning.

  3. Compare the preview against the original

    The result appears beside the original at the same display size. Look at the areas that compress worst: skin tones, gradients such as skies, and any text in the image.

  4. Try a different format if the quality is not acceptable

    If the picture looks poor at the size you need, converting rather than compressing is often the answer — the same photograph as WebP or AVIF will typically hit the target at a visibly higher quality than JPEG can.

  5. Download and check it where it is going

    Save the file, then look at it in the place it will actually be used. An avatar judged at full screen and then displayed at 48 pixels was judged at the wrong size.

Compressing is not the only lever, and often not the best one

Before you reach for quality, check the dimensions. A modern phone photograph is commonly four thousand pixels wide. If it is going to be displayed at eight hundred, you are storing five times more picture than anybody will ever see, and no amount of clever compression fixes that — you are compressing detail that is going to be thrown away by the browser anyway.

Resize first, compress second. Halving the width quarters the pixel count, and that alone usually gets you under the limit at a quality level where the image still looks good. It is almost always a better trade than keeping a huge picture and crushing it.

The exception is when the image will be printed, zoomed, or used as a source for something else later. Then keep the pixels and accept the size.

What lossy compression actually throws away

JPEG, WebP and AVIF all work on the same insight: the eye is far more sensitive to brightness than to colour, and far more sensitive to broad shapes than to fine detail. So they store colour at lower resolution than brightness, break the image into blocks, and describe each block in terms of a few coarse patterns rather than every pixel. Lowering quality keeps fewer patterns.

That is why the damage shows up first in specific places. Smooth gradients — skies, studio backgrounds, skin — turn into visible bands, because a gentle ramp is exactly what a small number of coarse patterns cannot describe. Sharp edges, especially text and line art, grow a faint halo. Flat blocks of colour survive almost anything.

Which means the right format depends on the picture. A screenshot with text in it compresses terribly as JPEG and perfectly as PNG. A photograph is the opposite. If the thing you are compressing is mostly text or flat colour, you are probably in the wrong format rather than at the wrong quality.

A rough guide to targets

For a photograph destined for a web page, 100–300 KB at the display size is a comfortable range and rarely looks compromised. For an avatar or thumbnail, under 50 KB is normally achievable without anyone noticing. For a document photograph — a receipt, an ID, a form — resist the temptation to go small: legibility matters more than bytes, and something under 1 MB is usually acceptable to whoever asked for it.

If you have to hit a number and cannot, the honest answer is usually to reduce dimensions further rather than to keep pushing quality down. A smaller sharp picture reads better than a large mushy one at every size either of them will ever be viewed at.

Questions

Things people ask about this

Does compressing an image remove its GPS location?

Re-encoding drops most metadata as a side effect, but do not rely on that as a privacy measure. If the location is the reason you are asking, check the file first with Check Photo Metadata so you know what was in it.

Can I compress a batch of photos at once?

Yes — the Bulk Image Tool takes up to fifty files and returns a single ZIP, applying the same settings to all of them. It runs in the browser like everything else, so a large batch is limited by your device rather than by a queue.

Why did my PNG get bigger when I compressed it?

PNG is lossless, so "compressing" it as PNG only reorganises the data and can occasionally cost more than it saves. If the image is a photograph, convert it to JPEG, WebP or AVIF. If it is a screenshot or line art, PNG is already the right format and the size it is.

Is quality 80 always the right setting?

It is a good starting point for photographs and a poor one for anything with text. The reason this tool works from a target size instead is that the correct quality number is a property of the individual image, not a general rule.