# Compress Image to Size

> Pick a size such as 50 KB or 100 KB, drop one image or a batch, and get the best quality that fits, with a before and after slider.

- Page: https://codethatmoves.com/tools/images/compress-image/
- Site: Code That Moves
- Category: Images and files
- Free, runs in the browser, nothing is uploaded (files you drop in stay on your device)
- Last checked: 2026-11-03

## What it does

- Paste a screenshot or copied image with Ctrl+V (Cmd+V on a Mac) instead of saving it first
- Compresses to a size you choose, with presets from 20 KB to 1 MB or a custom value such as 150 KB, 0.5 MB or 100 KiB
- Keeps quality at 50% or more while it can still scale the picture down, so the result does not turn to blocks
- Several images at once with the same target, downloaded one by one or as a ZIP
- Optional max width, for forms that also limit the pixel size
- Hands back your original file when it already fits and a re-encode would not be smaller
- JPEG or WebP output, EXIF orientation respected, metadata stripped; SVG and AVIF sources work too
- Before and after slider, sizes, dimensions and quality shown
- Runs in the browser, nothing is uploaded

## How to use it

1. Pick the size you need, or type your own such as 150 KB or 0.5 MB. A link such as ?target=50 opens with 50 KB chosen.
2. Drop one image or several. The tool tries qualities and sizes until it finds the best one that fits.
3. Check the result with the slider, then download it, or download all of them as a ZIP.

## What it checks and why

Many forms, ad platforms and email systems reject a picture over a fixed size. The usual way to hit it is to nudge a quality slider and check the file size again and again. This tool does the search for you: file size grows with quality, so it halves the range of qualities until it finds the highest one that stays under your target.

Quality does not drop below 50% while the picture can still lose pixels. When even that is too big, it estimates how much smaller the picture must be (bytes grow roughly with the pixel count), scales it down and searches again. A slightly smaller photo at decent quality looks better than a full-size one full of blocks. Turn on Keep the original dimensions if the pixel size must not change; then quality is allowed to go lower.

Sizes are counted in decimal units: 100 KB is 100,000 bytes. Some sites count 102,400, so a file under 100,000 bytes passes either way. If your file is already under the target and re-encoding would not make it smaller, you get your original back unchanged.

Everything happens in a canvas in your browser. Re-encoding drops the metadata a camera or phone writes into a photo, including the location, and the orientation is applied first so the picture is not turned sideways.

## Reference data

| Target | Typical use |
| --- | --- |
| 20 KB | Exam and passport photo forms |
| 40 KB | A banner backup image |
| 50 KB | Signature and ID photo uploads |
| 100 KB | Many web forms and profile photos |
| 150 KB | A common ad or email image limit |
| 200 KB | Application forms |
| 500 KB | Blog and CMS uploads |
| 1 MB | Email and chat attachments |

## Specs and sources

- [MDN: HTMLCanvasElement.toBlob()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
- [MDN: createImageBitmap()](https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap)
- [Google: WebP](https://developers.google.com/speed/webp)

## Limits

- JPEG and WebP are lossy formats, so some detail is lost. A PNG cannot be shrunk to an exact size by quality, which is why PNG output is not offered.
- A picture with fine noise or a lot of detail needs more bytes than a smooth one, so a very small target can force a smaller image.
- iPhone and iPad browsers cannot draw a canvas over 16.7 million pixels, so a larger photo (a 48 MP iPhone shot, for example) is reduced to fit that first, on every browser, and the result says so.
- WebP output needs a browser that can encode it. Safari before 17 cannot, and the option is disabled there.
- Animated GIFs are flattened to their first frame. Up to 20 images at a time.

## Questions

### How do I compress an image to 100 KB?

Choose 100 KB, drop the image and download the result. The tool picks the highest quality that stays under 100 KB and scales the picture down only if it has to.

### How do I compress a photo to 20 KB or 50 KB for an exam or passport form?

Choose 20 KB or 50 KB. If the form also gives a pixel size, type its width in Max width first, so the photo is scaled to that size and the quality search starts from there. Check the form's rules on format: most want JPEG.

### Is 100 KB 100,000 or 102,400 bytes?

Both are in use. This tool counts 1 KB as 1,000 bytes, so a result under 100 KB is under 100,000 bytes and passes a form that counts either way. Type 100 KiB if you need the binary value.

### Why is the result not smaller than my file?

Your file may already be under the target, or already compressed harder than the tool would go. A re-encode can come out larger than a well-compressed JPEG, so in that case you get your original back unchanged instead of a bigger file.

### Can I compress several images at once?

Yes. Drop up to 20 images; each one gets the same target, and Download all saves them as one ZIP. Click a name in the list to see its before and after.

### Why is my PNG still large?

PNG is lossless, so it cannot be tuned to a size with a quality setting. Convert it to WebP or JPEG here. For flat graphics with few colours, a smaller PNG needs a palette tool.

### JPEG or WebP?

WebP is usually 25 to 35 percent smaller at the same look and keeps transparency, but some systems still accept only JPEG. Use JPEG when a form or an ad platform asks for it.

### Does it remove the location from a photo?

Yes. The picture is redrawn and encoded again, which leaves out the EXIF block with the camera data and the location. The orientation is applied before that, so the picture stays upright. The one exception: when your original already fits and is handed back unchanged, its metadata stays.

### How do I make a photo smaller in KB without losing quality?

Scale it to the size it is shown at, then lower JPEG or WebP quality a step at a time while comparing with the original; this tool searches for the highest quality that fits your target. Lossless compression keeps every pixel but saves far less, and a photo saved as PNG usually shrinks most when it becomes JPEG or WebP.
