PoliteTools

Image Tools

Compress an image to an exact size

Type the size the upload form demands and get a file that fits it. Rather than making you drag a quality slider and re-check the result, this tool searches quality and dimensions for you and returns the best-looking image that lands at or under your target.

files never leave your device

Loading tool…

How to use Compress Image to Size

  1. Enter your target size, or tap one of the presets.

  2. Drop in a JPG, PNG or WebP — several at once is fine.

  3. Download the result. It is guaranteed to be at or under the target.

Why a quality slider can't promise a file size

Almost every image compressor online gives you a quality slider from 1 to 100 and leaves the rest to you. That works fine when your goal is vague — make this smaller, don't ruin it — but it fails completely when your goal is a number, because there is no fixed relationship between a quality setting and the size of the file that comes out. The same 70% setting might produce 40KB from a photograph of a blank wall and 900KB from a photograph of a forest.

The reason is that JPEG spends bytes on detail, and how much detail an image contains is a property of the image, not of the slider. A busy scene with texture in every direction is expensive to encode at any quality. A flat, evenly lit scan is cheap. So when a portal demands 20KB, a slider turns into guesswork: set it, export, check the size, adjust, repeat, often five or six times.

The fix is to make the tool do that loop instead of you. If the target is a real constraint, the software should treat it as one — encode, measure the actual bytes, adjust, and keep going until it has found the best-looking version that fits. That is what this tool does, and it is why it can promise the output size when a slider cannot.

How the search actually works

There are two independent ways to make an image smaller, and they damage it differently. Lowering JPEG quality keeps every pixel in place but introduces blocking and ringing artifacts, which are most destructive around sharp edges — text and thin lines suffer first. Reducing the pixel dimensions keeps the image clean but throws away fine detail permanently. Neither is strictly better; the right mix depends on what the image is for.

This tool works down a ladder of sizes, starting at full resolution. At each size it first tests the lowest quality it is willing to ship. If even that overshoots your budget, no quality at that size can fit, so it drops to the next size down without wasting further attempts. As soon as it finds a size where the floor fits, it binary-searches upward to find the highest quality that still lands under your target, and stops there.

The result is the largest, cleanest version of your image that satisfies the constraint, usually found in around fifteen encodes and well under a second. It also means the output lands just below your target rather than far beneath it — a 19.4KB result against a 20KB budget, not 6KB. Unused budget is quality you paid for and threw away.

KB, KiB, and the number the form is checking

There are two definitions of a kilobyte in common use. Storage manufacturers and some software use 1,000 bytes; operating systems, file managers and most upload validators use 1,024. The gap is small at first and compounds: a file your tool calls 20KB under the 1,000-byte definition is 19.5KB under the other, and one built to exactly 20,000 bytes can still be rejected by a portal measuring against 20,480.

This tool uses 1,024, because that is what the person filling in the form sees when they look at the file on their own computer, and it is what the great majority of upload validators compare against. Erring in this direction is also the safe one: a file sized against the smaller definition always satisfies a validator using the larger, while the reverse is exactly how you get an unexplained rejection.

When the target genuinely cannot be reached

Occasionally a budget is simply too small for the image — a detailed colour photograph squeezed under 5KB, for instance. Rather than returning a smear, the tool gives you the smallest legible version it can produce and marks it clearly as over target, so you know to change something rather than discovering the problem when the upload fails.

The fix is almost always cropping rather than more compression. Every pixel costs bytes whether or not it carries anything useful, so a signature photographed on a full sheet of A4 is spending most of its budget describing blank paper and paper texture. Cropping tightly to the subject before compressing routinely halves the file before the encoder does any work at all, and it improves the result far more than any setting can.

Frequently asked questions

Are my files uploaded to a server?

No. Everything happens locally in your browser using JavaScript and WebAssembly. Your files never leave your device, nothing is stored, and the tool even keeps working if you go offline after the page loads. That makes it safe for contracts, IDs, medical records and other sensitive documents.

How does it hit an exact size?

It encodes your image repeatedly at different quality levels and dimensions, measuring the real byte count each time, and keeps the largest, cleanest version that still fits your budget. That is why the result lands just under the target rather than far below it — anything left unused is quality thrown away for nothing.

Is KB here 1000 or 1024 bytes?

1024, which is what your operating system's file manager shows and therefore what the number in the upload form is being compared against. Using 1000 would let through files a portal then rejects, which defeats the point of setting a target at all.

What if my target is impossible?

You get the smallest legible version we can produce, clearly marked as over target, rather than an unusable smear. Cropping empty space around the subject is usually what fixes it — a signature surrounded by white paper spends most of its budget encoding the paper.

What next