Compress an image to a target file size
Choose an image, pick a target size (for example 200 KB) and press “Fit to target size”. The highest quality that stays under the target is found automatically, and you see the real output size.
Or drop it here. One JPEG, PNG or WebP image · up to 20 MB · 20 megapixels · 8,192 px on the long side. Your image never leaves this device.
Result
Choose an image to compare the original and the result here.
How it works
- The image is first saved at 95% quality. If that is larger than the target, the quality is narrowed down by halves between 10% and 95% to find the highest quality that fits.
- If even the lowest quality is too large, the width and height are reduced (keeping the aspect ratio) and the search runs again. It never goes below 320 px on the long side; if it still does not fit, you are told that the target could not be reached.
- The size shown is the size of the file actually created, not an estimate, and a file over the target is never offered as a result.
- Set a minimum quality to stop the search going below it, or turn off “Allow reducing the size” to keep the pixel size. If the target then cannot be reached, it is reported as not met — with what to change — instead of a result.
- Only JPEG and WebP are used. PNG has no quality setting, so its size cannot be steered. Transparent areas are filled with the background colour you choose.
- The image is never sent to a server; it is re-saved several times inside this browser. Large images can take a few seconds.
Is 1 KB 1,000 bytes or 1,024 bytes?
Some programs count 1 KB as 1,000 bytes and others as 1,024 bytes (for example Windows File Explorer). Sajinbaro aims for the smaller one, 1 KB = 1,000 bytes, so the file is under the target whichever way it is measured.
| Target | Upper limit used by Sajinbaro | Limit if 1 KB = 1,024 bytes |
|---|---|---|
| 100 KB | at most 100,000 bytes | 102,400 bytes |
| 200 KB | at most 200,000 bytes | 204,800 bytes |
| 500 KB | at most 500,000 bytes | 512,000 bytes |
| 1 MB | at most 1,000,000 bytes | 1,024,000 bytes |
What happens if I set the target too small?
Quality may drop a lot or the image may be scaled down, so text and faces can look blurry. The result shows the quality and size that were found, so check the preview; if the quality is not good enough, set a slightly larger target or resize the image to the dimensions you need first.
Is my image uploaded to a server?
No. The image is opened and saved again only inside this browser. It is never sent to a server, and the work pages carry no ads or third-party analytics. When you close the page, the image and the result are cleared from memory.
Is camera information such as location (EXIF) removed?
The image is redrawn and saved through the browser's canvas, so the original camera information is usually not carried into the result. This has not been confirmed for every browser and file, so removal is not guaranteed. If the photo contains sensitive information, check the result with another tool.
Sources and rules
- Canvas toBlob (MDN): How the browser saves an image in a chosen format and quality. If a format is not supported, the real output format is checked and you are told.
- createImageBitmap (MDN): How the image is opened. Rotation information (EXIF orientation) is applied where the browser supports it.