About the Compress to Exact Size Tool
Most compressors give you a quality slider and leave you guessing what file size you'll end up with. This one works the other way round: you tell it the size you need — 100 KB, 500 KB, 2 MB, or any custom value — and it finds the quality setting that lands as close to that as it can. It's built for the everyday situations where a form, portal or email has a hard limit: an upload that rejects anything over 500 KB, a passport or visa site capping photos at 100 KB, a job application, or a website that wants images under a certain weight.
How it works — the search for the right quality
There's no way to ask a browser for an image of exactly N kilobytes in one go — JPEG/WebP quality is a dial, not a size. So the tool does a binary search on the quality value:
- It re-encodes the image at a middle quality and measures the resulting file size.
- If the file is too big, it lowers the quality; if it's comfortably under the target, it nudges the quality back up to keep as much detail as possible.
- It repeats, halving the range each time, for up to about nine passes — quickly closing in on the highest quality that still fits under your target.
The result is the best-looking image that fits your size limit. The tool then shows you the actual size it achieved, so you always know exactly how close it got. Everything runs on a <canvas> in your browser with toBlob(); the image is never uploaded.
Assumptions and behaviour
- You choose the output format — JPEG (smallest, no transparency) or WebP (usually smaller still, keeps transparency). JPEG is the default because it hits small targets most reliably.
- The image keeps its original dimensions — only the compression quality is changed, not the width/height. To reach very small targets you may also need to resize (see the Limitations).
- The tool aims for the highest quality at or under your target, then reports the size it reached. If the target is easily met, it won't needlessly degrade the image.
- Nothing is uploaded, logged or stored.
Limitations — honest caveats
- It may not hit the exact number. Compression is approximate, so you'll usually land a little under the target (e.g. asking for 100 KB might give 94 KB). The tool always shows the real result rather than pretending it hit the number exactly.
- Some targets aren't reachable by quality alone. Asking for 5 KB from a large, detailed photo isn't possible without wrecking it — in that case the tool tells you plainly ("Couldn't reach 5 KB without heavy quality loss — closest: 18 KB") instead of returning a garbled image. To go smaller, resize the image first with the Resize Image tool, then compress.
- PNG has a size floor. PNG is lossless, so it can't be squeezed like JPEG. This tool reaches your target by re-encoding to JPEG or WebP — so a PNG input will change format (you'll be told). If you specifically need a PNG under a size, expect a much higher floor.
- It compresses one image at a time; for many at once, use the Bulk Image Compressor.
Privacy
The whole process runs in your browser with the Canvas API. Your image never leaves your device — nothing is uploaded or stored.

