Compress an image to a target size

Upload forms with a size limit are the reason most people compress an image at all. Name the limit and this gets under it, instead of leaving you to guess at a quality slider.

Why a target size rather than a quality slider

Most compressors give you a quality slider from 1 to 100 and leave the arithmetic to you. That is backwards for the situation almost everyone is in: a form says maximum 2 MB, and you need a file under 2 MB. Quality 70 does not tell you whether you got there.

The relationship between quality and file size depends entirely on what is in the photo. A picture of a clear sky and a picture of gravel compress completely differently at the same setting, sometimes by an order of magnitude. There is no reliable rule of thumb, which is why guessing means repeatedly saving and re-checking.

So this works the other way round: you give the size, and it finds the highest quality that fits underneath.

How it finds the right setting

The image is encoded at the highest sensible quality first. If that already fits, you get it — there is no reason to degrade a file that was never too large.

If it does not fit, a binary search narrows in: encode, measure, adjust, repeat. Eight probes narrow the quality range to under half a percent, which is far finer than the eye can detect, and it converges in a second or two rather than the dozens of manual saves the same result would take by hand.

The target is treated as a ceiling, never a goal. Landing at 180 KB against a 200 KB limit is a success; 201 KB is a failure, because the entire reason for a limit is that anything above it gets rejected.

When resolution has to give

Sometimes quality alone cannot get there. A 12-megapixel photo squeezed under 50 KB will look poor at any quality setting, because there are simply too many pixels to describe in that many bytes.

At that point the image is scaled down in steps and re-tried, and you are told exactly what happened — including the resolution it settled on. If even the smallest step misses the target, that is reported honestly rather than handing back an oversized file labelled as a success.

Nothing is uploaded

Compression happens in your browser. The file is read, re-encoded in memory, and handed back as a download — no server, no queue, no retention policy to read.

That also means there is no file size cap imposed by an upload limit, and no waiting behind other people's jobs. The only limit is your own device.

Quick questions

What size should I enter?

Whatever the form you are fighting with demands. Type '200 KB', '1.5 MB', or a plain number, which is read as kilobytes.

Will the result definitely be under my limit?

Where it is achievable, yes — the target is treated as a ceiling. If it cannot be reached even at the smallest size, you are told rather than handed an oversized file.

Does it reduce the resolution?

Only if quality alone cannot reach the target. If it does, the tool says so and reports the resolution it used.

Are my images uploaded?

No. Everything runs in your browser. Disconnect from the internet after the page loads and it still works.

Is there a maximum file size?

No server-imposed limit, because there is no server. Very large images are limited only by your device's memory.

Can I compress several images at once?

Yes — up to 200 per batch, each one fitted to the same target, downloadable as one ZIP.

Why is my output a JPG when I put in a PNG?

PNG is lossless and cannot hit an arbitrary size target for a photograph. JPG can, so photographic input is encoded as JPG.