This tool compresses an image to fit under a specific file-size limit — for instance the 200 KB cap many forms and uploaders enforce. Choose your target in kilobytes and it shrinks the image to fit while keeping it as sharp as possible. It is ideal for passport-photo uploads, job applications and any site that rejects files over a set size, and it works entirely in your browser.
How it works
The image is drawn onto an HTML canvas, then re-encoded as JPEG via canvas.toBlob, whose quality parameter (0 to 1) trades sharpness for size. To hit your target efficiently, the tool runs a binary search on the quality value: it tries a mid-level quality, checks whether the resulting blob is under your target, and narrows the range up or down accordingly. After a few iterations it settles on the highest quality that still fits. If even the lowest quality overshoots, it keeps the smallest result and reports its size.
Example
For a 1.8 MB photo with a target of 200 KB, the tool might test quality 0.5 (still too big), then 0.25 (under target), then 0.37, converging on, say, quality 0.31 that produces a ~195 KB JPEG. You download that file, comfortably under the limit and as sharp as the size allows.
All compression happens in your browser via the canvas API, so your image is never uploaded.