iLoveConverter
Categories 11 categories
Image Compression

Compress Image to an Exact Size – Hit Any KB Target

iLoveConverter Team 7 min read

On this page

Portals and forms love to announce a hard ceiling after you have already filled everything in: “photo must be under 200 KB”, “logo must be under 100 KB”. Re-saving a JPG with a lower quality slider and hoping is a guessing game — each guess costs an export, a file-size check, and usually another export. Our compress-to-size tool turns that guessing game into arithmetic: it binary-searches the quality scale and returns the highest quality that fits inside your target. Everything runs in your browser through WebAssembly — the file never leaves your device, there is no watermark, and there is no limit on attempts.

What the tool does

The tool encodes your image repeatedly at different quality levels and measures the file size after each encode. It starts at the middle of the quality scale, compares the result against your target, and throws away the half of the range that cannot be right — then repeats on the remaining half. A few iterations later it has converged on the boundary: the highest quality whose output stays under your target size. That boundary is what you get.

Two properties make this better than a manual slider:

  • Deterministic. The same image and the same target always produce the same answer. There is no “try 72, no wait, maybe 68” loop, because the search visits the quality scale systematically instead of by feel.
  • Maximizes quality for the budget. A human sliding down stops at the first visually acceptable result, which is usually far below the largest size the limit allows. Binary search spends your entire size budget: if 240 KB is the cap, the result lands a few KB under it at the highest quality that fits — not at quality 50 when quality 74 would have fit.

The output is always a JPG. That is a consequence of how the search works: it needs a quality dial to turn, and JPG has one. (PNG does not — more on that in the FAQ.)

Step by step

  1. Open the tool and drop in your image. JPG, PNG or another common raster format loads locally in the tab.
    • Expected result: a preview appears with a target-size input ready.
  2. Enter your target size. Type the ceiling in KB — for example, 200 for a 200 KB limit. Setting it a few KB below the official limit is a reasonable safety margin.
    • Expected result: the target is registered and shown next to the compress button.
  3. Run the compression. The tool binary-searches the quality scale — a handful of encode-and-measure passes, typically a few seconds for an ordinary photo.
    • Expected result: the result panel shows the final file size and the quality level that was found.
  4. Inspect the result. Look at the preview at full size: this is the highest quality that fits the target, which means any further compression would exceed the budget.
    • Expected result: the reported size is at or just under your target.
  5. Download the JPG. Keep the original file elsewhere; the compressed copy is for submission.
    • Expected result: the portal accepts the upload.

Parameters explained

  • Target size. The only decision you make, in kilobytes. Read the requirement literally: “under 200 KB” means the file must be at most 200 KB, so entering 200 is correct and entering 190 buys margin at a small quality cost.
  • Quality. Not a parameter you set — it is the output of the search. The tool reports the quality level it converged on, so you can see how much headroom the target left you: converging near the top of the scale means the image fits comfortably; converging near the bottom means the budget is tight for this resolution.
  • Output format. Always JPG. The search requires a quality dial, and JPG is the format that provides one. PNG input is accepted, but the result is still a JPG.
  • Output size. Guaranteed at or below the target when the target is reachable. If even the lowest quality exceeds your target, the tool returns its smallest result instead — at that point the image’s dimensions, not the quality scale, are the constraint.

When to use it

Government and university forms

Application portals are the classic case: a photo under 200 KB, a scanned diploma under 500 KB, a signature image under 50 KB. These limits are enforced by upload validation, and the fastest way to satisfy one is to hand the exact number to a tool that optimizes for it.

Marketplace and seller portals

E-commerce platforms cap product images per listing. When the cap is per-file rather than per-page, compressing each photo to just under the ceiling preserves more detail than a blanket re-encode at a guessed quality.

Email attachment budgets

A mailbox with a 25 MB attachment limit fills up fast with photos. Compressing each image to a size budget — 800 KB here, 1 MB there — keeps the whole message under the limit while every photo stays as sharp as its budget allows.

Tips for best results

  • Extreme ratios? Resize first. Squeezing a 6000-pixel photo into 20 KB bottoms out the quality scale. Shrinking the dimensions first costs far less visible quality than crushing quality alone — use the image resizer, then compress the smaller file.
  • PNG sources lose transparency. The output is JPG, so a PNG’s alpha channel is flattened. If the image must stay a PNG, use the dedicated PNG compressor instead — different tool, PNG stays PNG.
  • Don’t need an exact ceiling? Skip the target entirely and use the regular JPG compressor — for routine size saving without a hard limit, a straightforward quality choice is faster.
  • Keep the master file. Compression is lossy and permanent. Always keep the original; produce fresh compressed copies for each new limit rather than re-compressing an already compressed file.

Online tool vs desktop software

Desktop editors can hit a size target too — but through manual iteration: set quality, export, check size, lower quality, export again. The binary search automates exactly that loop and finishes it in a handful of passes, so the browser tool is both faster and more precise than hand-tuning. The privacy argument also matters for this tool specifically: form photos, IDs and diplomas are exactly the files people should not be uploading to a stranger’s server, and this tool never uploads anything — processing happens on your own machine, free, with no watermark and no cap. Desktop software remains the right environment when compression is one step inside a larger retouching pipeline.

FAQ

Why is the output JPG — even for PNG input?

Because the search needs a quality dial, and PNG has none: PNG is a lossless format with no quality knob to turn, so “find the highest quality under the target” has no meaning for it. JPG provides the dial. Feed the tool a PNG and you will get a JPG result — if the file must remain a PNG, use a PNG-specific compressor instead.

How close to the target will the file land?

Within a few KB. The binary search converges on the highest quality whose output stays under the target, so the result hugs the ceiling from below. If you want room for portals that measure size slightly differently, set the target a few KB under the published limit.

What if even the lowest quality exceeds my target?

Then the size target is unreachable at the image’s current dimensions, and the tool returns its smallest result so you have something to work with. The fix is to reduce the image’s pixel dimensions first — a smaller image at the same quality encodes to a much smaller file — and run the search again.

Is the quality loss visible?

The search returns the highest quality that fits, so for your size budget the result is the least lossy file possible — pushing quality any higher would break the limit. Whether the target itself is generous enough is a different question: a 6000-pixel portrait squeezed into 50 KB will look soft no matter who does the compression, which is why resizing first usually looks better than compressing harder.

Can I compress many images at once?

Drop files one after another and compress each to its own target — there is no quota and no watermark, and each result downloads separately. Form limits are usually per-file, so each image typically has its own ceiling anyway.

Try it yourself — free, right in your browser

Everything mentioned in this guide runs locally on this site: no upload, no watermark, no sign-up.

Format deep-dives: JPG (.jpg.jpeg.jpe)