Compress Image to Size
Published Updated
Pick a limit such as 100 KB and get the highest-quality JPEG that fits, scaled down only when quality alone is not enough.
Quality first, pixels only if needed
Upload forms care about bytes, not quality settings. This tool works backwards from your limit: it encodes the image as JPEG at quality 95 and checks the size; if that is too big it tries quality 5, and between the two it halves the gap eight times to find the best quality that still fits. Only when quality 5 is still too big does it shrink the picture in 10% steps and search again. These are the browser's own quality values: its canvas encoder takes a number between 0 and 1 for lossy formats such as JPEG, so 95 is passed as 0.95.
The result is the sharpest JPEG under your limit that this search can find.
One photo, five targets
A 2000 x 1500 test photo, 307,159 bytes as JPEG, run through this tool in Google Chrome 156:
| Target | Result | Pixel size |
|---|---|---|
| 500 KB | Original returned, 307,159 bytes | 2000 x 1500 |
| 200 KB | 183,374 bytes | 2000 x 1500 |
| 100 KB | 101,522 bytes | 2000 x 1500 |
| 50 KB | 51,154 bytes | 2000 x 1500 |
| 20 KB (custom) | 19,747 bytes | 1800 x 1350 |
Notice that 101,522 and 51,154 bytes fit the tool's 1,024-byte kilobyte but not a 1,000-byte one.
Typing a target for a form that counts in thousands
| The form says | Type in this tool | Largest file you can get |
|---|---|---|
| 50 KB (50,000 bytes) | 48 KB | 49,152 bytes |
| 100 KB (100,000 bytes) | 97 KB | 99,328 bytes |
| 200 KB (200,000 bytes) | 195 KB | 199,680 bytes |
| 1 MB (1,000,000 bytes) | 976 KB | 999,424 bytes |
The same photo and targets in three browsers
Each browser writes its own JPEG, so one quality value gives different file sizes and the search stops on different quality and pixel-size steps. The HTML standard defines the quality argument as the desired quality level, a number from 0.0 to 1.0, for formats with variable quality such as JPEG. Measured with this tool on a generated 2000 x 1500 photo (311,066 bytes as JPEG) in Google Chrome 157, Firefox 155 and Playwright's WebKit build (not the Safari app), each cell is the file size and the pixel size:
| Target | Chrome 157 | Firefox 155 | The WebKit build |
|---|---|---|---|
| 200 KB preset | 190,738 bytes, 2000 x 1500 | 198,442 bytes, 2000 x 1500 | 202,376 bytes, 2000 x 1500 |
| 50 KB preset | 51,143 bytes, 2000 x 1500 | 50,096 bytes, 1800 x 1350 | 50,585 bytes, 1400 x 1050 |
| 20 KB (custom) | 20,436 bytes, 1800 x 1350 | 20,055 bytes, 1200 x 900 | 20,466 bytes, 800 x 600 |
| 5 KB (custom) | 4,633 bytes, 600 x 450 | 5,048 bytes, 400 x 300 | 5,058 bytes, 200 x 150 |
| 1 KB (custom) | 1,486 bytes, 200 x 150, target not reached | 1,618 bytes, 200 x 150, target not reached | 3,106 bytes, 200 x 150, target not reached |
Wherever a target could be reached, all three results are at or under it. For the 1 KB target the tool hands back its smallest try, at 10% of each side, with the message that the target cannot be reached.
Large PNGs, transparent logos and tiny pictures
Three more generated files, same tool, same three browsers. The noise PNG compresses badly, so it is a hard case. The logo is a PNG with transparent areas.
| File and target | Chrome 157 | Firefox 155 | The WebKit build |
|---|---|---|---|
| Noise PNG, 3000 x 2000, 18,027,686 bytes: 1 MB preset | 1,000,452 bytes, 3000 x 2000 | 1,032,855 bytes, 3000 x 2000 | 1,047,536 bytes, 2700 x 1800 |
| Noise PNG: 50 KB preset | 40,503 bytes, 2100 x 1400 | 45,569 bytes, 1500 x 1000 | 50,963 bytes, 900 x 600 |
| Logo PNG with transparency, 800 x 500, 20,332 bytes: 50 KB preset | Original returned, logo-50kb.png | Original returned, logo-50kb.png | Original returned, logo-50kb.png |
| Logo PNG: 10 KB (custom) | 10,220 bytes, 800 x 500, logo-10kb.jpg | 10,206 bytes, 800 x 500, logo-10kb.jpg | 10,205 bytes, 720 x 450, logo-10kb.jpg |
| Smooth JPEG, 400 x 300, 12,693 bytes: 1 KB (custom) | 981 bytes, 120 x 90 | 1,010 bytes, 120 x 90 | 1,020 bytes, 40 x 30 |
The top-left pixel of the logo is transparent in the PNG and measured white (255, 255, 255) in every JPEG result, because the tool paints white under the picture first.
Hitting a file size
Step 1
Add a JPG, PNG or WebP image
The pixel size and original file size are shown, so you can see how far it has to shrink.
Step 2
Pick a target
50 KB, 100 KB, 200 KB, 500 KB or 1 MB, or type your own number in KB or MB. 1 KB here is 1,024 bytes.
Step 3
Compress and download
The tool searches for the highest JPEG quality that fits, shrinks the picture only if it must, and saves a .jpg.
Before or after compressing
- Choose the quality yourself: Image Compressor.
- Set exact pixel dimensions first: Resize Image.
- A PDF with a size limit: Compress PDF to Size.
- Passport photos cropped to 2 x 2 in or 35 x 45 mm: Passport Photo Size.
Compressing an image to a size limit
My form says 100 KB but rejects the file. Why?
This tool counts 1 KB as 1,024 bytes, so a 100 KB target allows up to 102,400 bytes. Some forms mean 100,000 bytes. In a test, the 100 KB preset produced a 101,522-byte file, which such a form would refuse. Type 97 KB instead to stay under 100,000 bytes.
Does it reduce the width and height?
Only when quality alone cannot reach the target. It tries full size first, then 90%, 80% and so on down to 10%. In a test, a 2000 x 1500 photo met 50 KB at full size but needed 90% (1800 x 1350) to reach 20 KB.
Why is the result always a JPG?
JPEG has a quality setting the tool can search, which is what makes hitting a byte size possible. PNG is lossless and has no such setting. Transparent areas are filled with white first.
What if my image is already under the target?
You get your original file back, untouched and in its original format, with a message that it already fits. The name keeps that format's extension, so a PNG under a 100 KB target downloads as name-100kb.png.
How small can it go?
Down to quality 5 at 10% of the pixel size. If even that is too big, you get the smallest result with a message that the target cannot be reached without making the image unusable.
Which target should I use for a passport or visa photo upload?
Use the limit the form states, a little under it if the form counts in thousands of bytes. Check the required pixel size as well: this tool lowers the pixel size only as a last resort. Passport Photo Size crops to a 2 x 2 inch or 35 x 45 mm frame before you compress.
Does it work with very wide panoramas?
Up to 65,500 pixels wide or tall, because the result is always a JPEG and this page saves JPEGs up to that size. A 65,535 x 8 picture gets a message with its size and no file in Chrome 156, Chromium 153 (Playwright build, not Google Chrome), Firefox 155 and the WebKit build. Make it smaller first, for example with Resize Image.
Why did the same target give a different pixel size in another browser?
Each browser has its own JPEG encoder, so one quality value gives different bytes. On the 2000 x 1500 test photo a 50 KB target stayed at 2000 x 1500 in Chrome 157, dropped to 1800 x 1350 in Firefox 155 and to 1400 x 1050 in the WebKit build. Pixel size is the tool's second step, so it follows the encoder of the browser you use.
Does a transparent PNG stay transparent?
Only when the file is returned unchanged. An 800 x 500 PNG of 20,332 bytes with transparent areas came back as it was for a 50 KB target and downloaded as logo-50kb.png. For a 10 KB target the result was a JPEG named logo-10kb.jpg, and the pixel that was transparent measured white (255, 255, 255) in Chrome 157, Firefox 155 and the WebKit build.
Can an 18 MB PNG be brought down to 1 MB?
A 3000 x 2000 PNG of random noise, 18,027,686 bytes, came out at 1,000,452 bytes in Chrome 157, 1,032,855 in Firefox 155 and 1,047,536 in the WebKit build, all under the 1 MB preset of 1,048,576 bytes. The WebKit result was 2700 x 1800 and the other two kept 3000 x 2000. The search took between 0.46 and 0.72 seconds.
How big is the result when the target is too small to reach?
It is the smallest picture the tool can make: quality 5 at 10% of each side, with a message that the target cannot be reached. A 1 KB target on the 2000 x 1500 test photo gave 1,486 bytes in Chrome 157, 1,618 bytes in Firefox 155 and 3,106 bytes in the WebKit build, all at 200 x 150 pixels.