🗜️ Image Compressor
An image compressor for JPG, PNG and WebP to an exact file size or by quality. Runs in your browser — nothing is uploaded. Batch, EXIF removed.
Choose images, or drop them here
JPG, PNG, WebP, GIF, BMP. They are compressed in this tab and never uploaded.
The quality is found by encoding and measuring, not estimated, so the result lands at or just under the number you set.
What Image Compressor Does
Image compression trades detail you are unlikely to notice for bytes you certainly will. JPEG and WebP do this by discarding high-frequency information the eye resolves poorly — fine texture, subtle gradients in flat areas — and the "quality" number you set is really a knob on how much gets thrown away. PNG works the opposite way: it keeps every pixel exactly and finds its savings in repetition, which is why it excels on screenshots and logos and struggles on photographs.
The thing most compressors get wrong is that people rarely want a quality number. They want a file under a limit: a portal that rejects anything over 200 KB, an application form capped at 100 KB, an email that will not send. Quality does not map to file size in any predictable way — the same setting produces wildly different sizes for a blue sky and a crowd scene — so a slider can never answer "will this clear the limit?" in advance.
This tool answers it by measuring. It encodes the image, checks the actual byte count, and adjusts, narrowing the quality range by half each pass until the result sits at or just under your target. When even the lowest usable quality overshoots, it starts reducing resolution instead, because past a certain point fewer well-encoded pixels look better than more badly-encoded ones.
The whole thing runs in your browser. Nothing is uploaded, which also means the output carries no EXIF: re-encoding through a canvas produces a file of pure pixels, so the camera model, timestamp and the GPS coordinates a phone writes into every photo do not survive the trip.
How to Use Image Compressor
- Add one or more images, or drop them onto the box
- Pick "to a target size" and type the limit in KB, or switch to quality and set a number
- Choose an output format, or keep the original
- Compress, check the before-and-after sizes, and save
Formula Used by Image Compressor
Finding the quality that hits a target size
binary search on q ∈ [0.30, 0.95]: encode(q), measure bytes, keep the highest q whose output ≤ target
- q
- JPEG or WebP quality passed to the encoder, 0 to 1
- target
- the byte limit you set, e.g. 200 KB = 204,800 bytes
- 0.30
- the practical floor — below it a JPEG stops shrinking meaningfully and starts visibly breaking up
Worked example
A 3.4 MB photo, target 200 KB. Nine passes of the search.
- Encode at q = 0.30 first. If even that overshoots the target, no quality on this image can reach it, so drop the resolution and start again.
- It fits, so search upward: try the midpoint of [0.30, 0.95] — q = 0.625.
- Too big → the answer is below 0.625; try the midpoint of [0.30, 0.625].
- Small enough → the answer is at least that; search the upper half.
- Each pass halves the remaining interval: after nine, the range is 0.65 ÷ 2⁹ ≈ 0.0013 wide.
Result: The highest quality whose encoded output is ≤ 200 KB, pinned to about one part in a thousand — nine encodes, not a guess.
Which format to compress to
The choice matters more than the quality setting. A photograph forced into PNG, or a screenshot forced into JPG, loses more than any slider recovers.
| Format | Compression | Transparency | Best for | Avoid for |
|---|---|---|---|---|
| JPG | Lossy | No | Photographs, scans, anything with continuous tone | Logos, screenshots, text, line art |
| PNG | Lossless | Yes | Screenshots, logos, flat color, sharp edges | Photographs — files run several times larger |
| WebP | Both | Yes | Almost everything on the web; 25–34% below JPEG at equal SSIM | Workflows that must open in very old software |
| GIF | Lossless, 256 colors | Yes, 1-bit | Short animation only | Any still image — WebP or PNG beats it comprehensively |
Source: Google — WebP Compression Study
Common size limits worth compressing to
Where the target-size mode earns its keep. Check the exact limit at the source — portals change theirs without notice.
| Where | Typical limit | Sensible target |
|---|---|---|
| Gmail attachment | 25 MB per message | Well under; larger files are replaced with a Drive link |
| Government and job portals | Often 100–500 KB per image | Set the exact number the form states |
| A web page hero image | No hard limit; page weight is the constraint | 150–300 KB at the size it is displayed |
| A blog body image | No hard limit | 60–150 KB is usually indistinguishable from more |
How to Read Your Result
Quality 75 to 85 is the useful range
Above 90 you are spending bytes on differences almost nobody can see; below about 60 the blocky artefacts around edges and in gradients become obvious. If a target-size run reports a quality below 50, the target is probably too tight for the image and you would get a better-looking result by reducing the resolution deliberately.
A result larger than the original is real, not a bug
It happens with PNG. This tool re-encodes through the browser rather than running a dedicated PNG optimizer, so a PNG that has already been through pngquant or oxipng can come out larger. The row says so rather than hiding it behind a clamped "0% saved". For those files, convert to WebP instead — it keeps transparency and is genuinely smaller.
Compressing twice compounds the loss
Every lossy save discards more, and the losses do not cancel out. Compress once from the original whenever you can. If you are editing, keep a lossless master and compress only the final export.
Limitations & Accuracy Notes
- PNG output is a browser re-encode, not a dedicated optimizer. It will not match pngquant or oxipng, and on an already-optimized PNG it can be larger.
- EXIF, ICC color profiles and GPS data do not survive. That is usually welcome, but if you need the camera metadata kept, use a tool that preserves it.
- A wide-gamut photo tagged with a Display P3 profile loses that tag and is treated as sRGB, which can shift saturated colors slightly.
- Very large images are held in memory while they are processed, so a phone with little free RAM may fail on a 50-megapixel file where a laptop will not.
- Animated GIFs and animated WebP are flattened to their first frame — this compresses still images only.
Frequently Asked Questions
How do I compress an image to exactly 100 KB?
Are my images uploaded anywhere?
Does compressing an image lose quality?
Why did my transparent PNG come out with a white background?
Does this remove EXIF and GPS data from my photos?
Can I compress several images at once?
Why can my image not reach the size I asked for?
References & Further Reading
- Google — WebP Compression Study — Source of the 25–34% figure, measured against JPEG at equal or better SSIM
- MDN — HTMLCanvasElement.toBlob() — The encoding API this tool uses, including how the quality argument behaves
- ITU-T T.81 — the JPEG specification — The original 1992 standard describing the DCT-based lossy compression JPEG uses
- Google — Gmail attachment size limits