How to Compress an Image to an Exact File Size (1 MB, 2 MB, 500 KB)
Upload forms give you a byte limit, not a quality setting. How to hit a specific file size without guessing, why the limit exists, and what to do when the image will not go small enough.
The Talentra Editorial Team
Research and editing
Published
7 min read
How do I compress an image to exactly 1 MB?
You cannot hit a byte count exactly, and you do not need to — a limit is a ceiling, so the aim is the highest quality that lands just underneath it. The reliable method is a binary search: encode at quality 60, and if the result is under the limit try 78, and if that fits try 87, narrowing until you find the highest setting that still fits. A tool with a target-size mode does this automatically in about eight attempts.
Almost nobody wants a photograph at 62 per cent quality. What they want is for it to be under 2 MB, because a form said so and refused to accept it otherwise. The searches bear this out: people look for how to compress an image to 1 MB, to 2 MB, to 5 MB, to 500 KB — always a specific number, never a quality setting.
This guide covers how to hit a byte target reliably, why quality settings are a poor way to get there, and what to do when the image refuses to cooperate.
Why a quality setting is the wrong control
Image compression quality is not a percentage of anything you can predict. Setting quality to 70 does not produce a file 70 per cent of the original, and it does not produce the same size on two different photographs.
The reason is what compression actually does. A lossy encoder looks for redundancy — regions it can describe more cheaply than pixel by pixel — and how much it finds depends entirely on the content:
- A photograph of a clear sky at dusk is mostly smooth gradient. An encoder can describe enormous areas with very little data. It might compress twenty to one.
- A photograph of gravel, autumn leaves or a crowd is fine random detail everywhere. Almost nothing is predictable from its neighbours, so almost nothing can be discarded without visible damage. The same encoder might manage four to one.
Both files came off the same camera at the same settings. One is 900 KB and the other is 6 MB, and no quality number tells you in advance which you are dealing with. This is why guessing at the slider is frustrating: you are adjusting an input when what you have is a constraint on the output.
The method that actually works: search, do not guess
If you know the ceiling, the sensible approach is to work backwards from it, and the efficient way to do that is a binary search.
Encode the image at a middling quality — say 58 — and look at the result:
- If it fits under the limit, you have headroom. Try higher: 77.
- If 77 fits too, try 87. If it does not, try 67.
- Each attempt halves the remaining range.
Eight rounds of this narrows a range from 20–96 down to a single point. That is a finer distinction than the eye can see between adjacent quality values, and it lands you at the highest quality that still fits, rather than at some arbitrary setting well below the limit.
This is worth doing by hand once, to see how it behaves. After that, use a tool that does it for you. The image compressor on this site has a mode where you choose the size rather than the quality — 100 KB up to 10 MB — and it runs exactly this search, then tells you which quality it settled on.
The point of reporting the quality back is not decoration. If it says 91, the image had room to spare and you know the limit was not really binding. If it says 22, the result is going to look rough and you should be resizing instead.
When quality alone cannot get there
There is a floor. Below roughly quality 20, JPEG and WebP both produce visible blocking, colour banding and smeared edges — the image is under the limit and no longer worth sending.
If the search bottoms out and the file is still too big, the pixel count is the problem. This is extremely common, because modern phone photographs are enormous: a 48-megapixel image contains twelve times the pixels of a 1080p screen.
Reduce the dimensions. Halving the longest edge quarters the pixel count, and that is a far larger lever than quality:
| Change | Effect on file size | Effect on appearance |
|---|---|---|
| Quality 90 → 60 | roughly halves | slight softening, some artefacts |
| Quality 60 → 30 | roughly halves again | clearly degraded |
| Width 4000 → 2000 px | roughly quarters | looks clean, just smaller |
| Width 4000 → 1000 px | roughly one sixteenth | looks clean at its new size |
A 4000-pixel photograph resized to 1500 pixels at quality 80 will nearly always look better and weigh less than the same photograph at 4000 pixels and quality 35. Our guide on dimensions versus file size explains why this is so consistently true.
The exception is when the form specifies a minimum resolution as well as a maximum file size — passport and visa photograph requirements often do exactly this. Then you are genuinely boxed in, and the answer is a better format rather than fewer pixels.
Change the format, if the form allows it
Format choice moves the numbers more than most people expect:
- WebP typically reaches the same visual quality as JPEG in 25 to 35 per cent fewer bytes. Browser support has not been a practical constraint for years.
- AVIF is smaller still, though encoding is slower and support is thinner in older software.
- PNG for a photograph is the mistake to avoid. It is lossless, so it stores every pixel exactly, and a photograph converted from a 2 MB JPEG to PNG can easily reach 12 MB. PNG is for screenshots, diagrams and transparency.
The constraint is not technical, it is administrative: many upload forms accept only JPEG or PNG. A beautifully compressed WebP is rejected regardless of size. Read what the form accepts before optimising for a format it will not take.
The common limits, and why they are so awkward
| Context | Typical limit | Why it hurts |
|---|---|---|
| Job application portals | 1–2 MB | A single phone photo of a certificate often exceeds it |
| Government and visa forms | 500 KB – 1 MB, sometimes with a minimum resolution | Two constraints pulling in opposite directions |
| Email attachments | 20–25 MB total | Fine for one photo, not for twelve |
| Forum and CMS uploads | 2–8 MB | Usually workable |
| Marketplace listings | 5–10 MB each | Rarely a problem |
Most of these numbers were set when a good camera produced a 2 MB file. Phone cameras have grown by an order of magnitude and the limits have not moved, which is why this problem is more common now than it was a decade ago, not less.
The privacy question nobody asks
The files people most often need to squeeze under a limit are the ones they should be most careful with: a scanned passport, a bank statement, a signed contract, a photograph of a child for a school form.
Most online compressors work by uploading your file to a server, processing it there, and returning a link. That is a copy of your identity document on a machine you know nothing about, governed by a retention policy you have not read, at a company you found through a search result.
A browser-based tool does the work in the page itself using the canvas API. The file is read into memory, re-encoded, and written back to your downloads folder without a single byte being transmitted. You can verify this yourself: open the network tab in your browser's developer tools and compress an image. If nothing is uploaded, nothing was uploaded.
That is how our compressor works, and it is the reason it works offline once the page has loaded.
The short version
- Work from the limit, not the slider. The target is the highest quality that fits underneath it.
- Search rather than guess. Eight halvings of the range gets you there; a tool with a target-size mode does it in a second.
- If quality bottoms out, resize. Dimensions are a much bigger lever, and the result looks better.
- Check what the form accepts before converting to WebP.
- For anything personal, use a tool that does not upload the file.
Sources
Primary references used in this guide. Rules change — check the source directly if you are relying on it for a decision.
About this guide
Talentra's editorial team researches, drafts and fact-checks every guide on this site, and revisits each one when the underlying rules change. This page was last reviewed on August 24, 2026. It is general information, not legal, tax or financial advice — see our disclaimer and editorial policy. Spotted something out of date? Tell us.