Compress an image to an exact file size
Tell it a limit — 100 KB, 500 KB, 2 MB — and it finds the best quality that still fits under it. Unlike a quality slider, you do not have to guess and re-export until the number goes green. Everything runs in your browser; the images are never uploaded.
Why "target a size" beats "pick a quality"
Every image editor has a quality slider from 1 to 100. It is a poor interface for the job most people actually have, because the number you care about is not quality — it is the file size that a form, an email attachment limit or a marketplace will accept.
The relationship between the two is not something you can calculate in your head. Quality 80 on one photo might produce 90 KB or 900 KB depending on how much detail and noise it contains. So the normal workflow becomes trial and error: export, check the size, drop the quality, export again. Three or four rounds per image, and a different answer every time.
Reversing the question fixes it. State the constraint first — "must be under 200 KB" — and let the tool search for the highest quality that satisfies it.
How the search works
The encoder is a black box: you give it a quality value and it gives you a file. But it responds predictably — lower quality always produces a smaller file. That monotonic behaviour means a binary search finds the answer in a handful of attempts rather than by sweeping every value.
- Encode at the midpoint of the current range and measure the result.
- If the file is within the target, the true answer is at least this quality — discard the lower half.
- If the file is over the target, discard the upper half.
- Repeat. Seven or eight rounds narrow the range enough that the remaining difference is invisible.
That is roughly eight encodes instead of the dozens a linear sweep would need, which is what makes this practical to do in a browser on a two-thousand-pixel photo.
When quality alone cannot reach the target
There is a floor. Below roughly quality 30 to 40 on a JPEG, further reductions buy very little size and start destroying the image — blocky artefacts around every edge, banding in smooth gradients, text that turns to mush. If the target is below what the smallest sensible quality produces, the only lever left is resolution.
At that point the tool estimates how much smaller the image needs to be. Since file size scales roughly with pixel count, halving the pixel count roughly halves the size — so the required linear scale factor is about the square root of the ratio between the target size and the smallest size achievable at the current dimensions. The image is resampled once and the quality search runs again.
| What you change | Effect on file size | Effect on how it looks |
|---|---|---|
| Quality 90 → 70 | Large — often 40–60% smaller | Barely visible on photos |
| Quality 70 → 40 | Moderate — 20–40% smaller | Visible artefacts on edges and text |
| Quality 40 → 20 | Small — often under 15% | Obvious damage |
| Dimensions −25% | About 44% smaller | Softer, but clean — usually the better trade |
| Dimensions −50% | About 75% smaller | Clearly lower resolution on zoom |
The practical rule that falls out of it: cut resolution before you cut quality below about 40. A clean 1200-pixel image at quality 85 looks better than a mangled 2400-pixel one at quality 25, and it is smaller too.
The limit you are probably up against
| Where | Typical limit |
|---|---|
| Web forms and upload fields | 2 MB, sometimes 1 MB |
| Email attachments | 20–25 MB total, so often about 5 MB per image after encoding overhead |
| Marketplace listing images | 10 MB per image is common; some are stricter |
| Resume and application portals | Often 100–500 KB for a photograph |
| Thumbnails and avatars | 20–50 KB |
| Performance budgets on your own site | 150–300 KB per image is a reasonable target |
One caution about the mobile web: WhatsApp, WeChat and similar messengers re-compress images they send, and they are aggressive about it. If you are preparing a photo to send through a messaging app, compressing it here first is still worth it — the app will damage it less if it is handed something already close to the limit.
Format notes that actually matter
- JPEG is the right default for photographs, and the only format where a quality parameter behaves as described.
- WebP typically produces a file 25–35% smaller than JPEG at equivalent visible quality. That is a real advantage when you are fighting a hard limit, but some older upload pipelines still handle it poorly. If a form rejects your file, try JPEG before assuming the size is the problem.
- PNG is lossless, so there is no quality to search — the only lever is dimensions. It is the wrong choice for a photograph you are trying to squeeze, and the right choice for a screenshot containing text or flat colours. If you select PNG and a target that cannot be met, the tool will tell you rather than silently producing something else.
Common ways people break their own images
- Compressing the already-compressed file. Each JPEG pass loses a little more. Export from the original every time — the tool always starts from the file you give it, but it cannot undo damage from a previous round.
- Setting a target that is too aggressive. "Under 50 KB" for a 4000-pixel photograph means throwing away most of the detail. If the image will be viewed full-screen anywhere, 200–400 KB is a saner target.
- Using PNG for photos and wondering why nothing shrinks. PNG is lossless by design. Converting a photograph to PNG and then trying to compress it is working against the format.
- Resizing after compressing. If the final image also needs specific pixel dimensions, resize first and compress afterwards. Resizing a compressed file means compressing twice.
- Trusting the file manager's size column. Windows and macOS report sizes differently (KB vs KiB, and disk usage vs actual size), which is why a file that "should be 200 KB" shows as 204 KB. What matters is the limit enforced by whoever is receiving the file.
Questions
Are my images uploaded?
No. The encoding is done by your own browser using the canvas API, and each result is produced from an in-memory copy. Turn off your network after the page has loaded and the tool still works — that is the test.
Is there a limit on how many images I can process at once?
No limit is imposed, but every image is searched and held in memory. On a low-end device, a few hundred large photos in one batch can exhaust it. Working in batches of a few dozen is comfortable.
Why can it not reach the target size I asked for?
Either the target is below what the format can produce at any sensible quality, or dimension reduction is switched off. Turn on dimension reduction and try again, or raise the target. For a target under about 20 KB, PNG will never get there for a photograph.
Why is my PNG not getting smaller?
PNG is a lossless format, so there is no quality setting to reduce. The only lever is pixel dimensions. Convert to JPEG or WebP first if the image is a photograph.
Does compressing remove the metadata?
Yes for the common cases. Re-encoding through a canvas drops EXIF data, which means GPS coordinates embedded by a phone camera are removed as a side effect. If you specifically need the original metadata preserved, keep the source file — this tool exports a new one and never modifies the original.
Should I compress before or after resizing?
Resize first, compress second. Resizing a compressed file means encoding twice, and each JPEG pass costs quality. If you need a specific pixel size, use the resize tool first with transparency or PNG output, then compress the result here.