Compress Image to Target Size

Shrink a photo to a target file size, e.g. under 200 KB.

Free tool to compress an image to a specific target file size in KB. Binary-searches the JPEG quality to fit your photo under a chosen size limit. Runs entirely in your browser — no upload. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How does it hit a specific file size?

It binary-searches the JPEG quality setting, re-encoding the image at successively narrowed quality levels until the result is at or below your target size while keeping quality as high as possible.

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.

Why binary search instead of just lowering quality step by step

JPEG quality is not a linear slider — going from quality 0.9 to 0.8 might cut file size by 40%, while going from 0.3 to 0.2 barely changes it. A brute-force approach that walks down quality in fixed steps would waste time in regions where the size barely changes and might overshoot the target in regions where it changes fast. Binary search navigates this efficiently: it always cuts the search range in half, typically reaching an accurate result in 6–8 re-encodes regardless of where the answer sits on the quality curve.

Common file-size targets by use case

Use caseTypical limit
UK passport or visa photo upload2 MB or smaller
Job application portal photo200–500 KB
Government form ID photo100–300 KB
Email inline image100–200 KB
Website product thumbnail50–150 KB
WhatsApp / messaging (no resize)Under 5 MB

If a form rejects your image for size, this tool is the fastest fix — no account, no upload, no waiting.

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.

Practical notes and limitations

  • JPEG only. PNG and WebP images are re-encoded as JPEG. If your original is PNG with transparency (like a logo on a white background), the transparent areas become white after conversion. If preserving transparency matters, resize the image dimensions instead of compressing.
  • Resolution vs. quality. This tool adjusts JPEG quality, not pixel dimensions. For very large images (e.g., 4000×3000 pixels), lowering quality enough to hit a tight size limit (like 50 KB) will produce visible artefacts. In those cases, resize the image first to smaller dimensions, then compress — you’ll get a better result at the same file size.
  • What to do if the target can’t be reached. If even quality near zero overshoots your target, the image is too high-resolution for that limit. Use an image resizer first to reduce the pixel dimensions, then compress.

All compression happens in your browser via the canvas API, so your image is never uploaded.