Open Source
I built a way to compress a photo to 50 KB without uploading it anywhere

The point in two sentences
The photos people compress and resize online are often the private ones: a passport photo, a signature, a picture of their family with GPS still in it. I built Image Tools, free image tools that do all the work inside your browser tab, including compressing to the exact size a form asks for, so the photo never leaves your device.
“Upload a photo under 50 KB”
If you have filled in an exam form, a job application or a visa form, you have met this box. The photo must be under 50 KB. The signature must be under 20 KB. Sometimes there is a pixel size too.
So you search “compress image to 50 KB”, open the first result, and upload your face to a server you know nothing about. Then you guess at a quality slider until the number comes out right, and re-upload when it doesn’t.
Both parts bothered me. The upload isn’t needed: browsers can now run real image encoders compiled to WebAssembly. And the guessing isn’t needed either: if you know the size you want, the computer can find the setting.
What it does
Seventeen tools, each on its own page:
- Compress: any image, JPEG or PNG, with a quality slider or a target size in KB
- Resize: by pixels, percent or longest side, or to passport (35 × 45 mm at 300 DPI), Instagram, YouTube, LinkedIn, X and link-preview sizes
- Crop, rotate and flip, with presets like 1:1, 4:5 and 16:9
- Convert between JPG, PNG, WebP and AVIF, and from HEIC (iPhone photos), GIF and BMP
- Favicon generator:
favicon.ico, the PNG sizes, asite.webmanifestand the HTML to paste - Image to Base64, for dropping small images into code
- Remove EXIF: strip GPS and camera details without re-saving the picture
There are also ready-made pages for the sizes people actually search for: compress to 20 KB, 50 KB, 100 KB, 200 KB and 500 KB.
No sign-up, no watermark, no daily limit, and you can drop in a batch and get a ZIP back.
How “compress to 50 KB” works
You type the size. The tool then searches for the best result that fits, in two layers.
First it looks for the highest quality that fits at full size. It saves the image at the best quality; if that already fits, it’s done. If not, it tries the lowest quality; if even that is too big, it knows quality alone won’t get there. Otherwise it does a binary search between the two: try the middle, keep whichever half the answer must be in, repeat. A handful of tries is enough to land within a point or two of the best possible quality.
If even a modest quality won’t fit, the image is too big in pixels for that budget, so the tool makes it smaller and searches again. File size grows roughly with the number of pixels, so it shrinks each side by the square root of how far over it is, rather than halving blindly. A 4000-pixel phone photo squeezed into 20 KB comes out as a smaller image that still looks clean, instead of a full-size one that looks like it was saved in 2003.
Two small rules keep it honest. If your original already fits, you get it back untouched. And if nothing fits, it tells you and gives you the smallest version it could make, instead of quietly handing you something over the limit.
The search itself is a few dozen lines of plain JavaScript with no browser code in it, so it is tested in Node with a fake encoder. The encoding happens elsewhere.
The encoders, all in the page
The image work is done by the same open-source encoders that desktop tools and servers use, compiled to WebAssembly through the jSquash project:
- MozJPEG for JPEG, which is built to make smaller files than a standard JPEG encoder at the same quality
- libwebp for WebP and libavif for AVIF
- OxiPNG for PNG, plus a small colour reducer I wrote, because a PNG only gets much smaller when it uses fewer colours
They run in a background worker so the page doesn’t freeze, and each one downloads only when you need it. Someone who only resizes a JPEG never downloads the 3.5 MB AVIF encoder.
iPhone photos were their own small puzzle. Safari can open HEIC files itself, but Chrome and Firefox can’t. So the tool asks the browser first, and only if that fails does it load libheif, about 2 MB, to decode the photo. Safari users never download it.
Removing GPS without touching the picture
Most “remove EXIF” tools work by opening the image and saving it again. That strips the metadata, but it also re-compresses the photo, so you lose a little quality to remove a few hundred bytes of text.
Image Tools doesn’t re-save anything. A JPEG file is a series of labelled blocks: one holds EXIF (camera, date, GPS), others hold comments or other metadata, and one holds the picture itself. The tool walks the blocks, drops the metadata ones, and copies the picture data across byte for byte. PNG and WebP work the same way with their own kinds of blocks.
There was one catch. Phones often don’t rotate the photo itself; they save it sideways with a tag that says “turn me 90 degrees”. Remove all the EXIF and the photo suddenly shows up sideways. So when a photo depended on that tag, the tool writes back a tiny EXIF block holding only the rotation and nothing else.
For a closer look at what a photo carries, including why some get an “AI info” label on social media, there is a separate tool, TagLens.
“Never uploaded” is easy to say, so here is how to check
- Turn off your Wi-Fi. Load a tool, disconnect, then use it. It still works, because there is no server involved.
- The page is locked to itself. The site sends a Content Security Policy that only lets the page connect to its own address, plus the newer Connection-Allowlist header in recent Chrome and Edge. Every encoder is served from the site itself, never from a CDN, so nothing else needs to be allowed.
- Read the code. It is all on GitHub under the MIT licence, with the encoders keeping their own licences.
What it deliberately does
Every image the tool re-saves comes out without metadata. That means no GPS and no camera details, even when you only asked to resize. I went back and forth on this and settled on it: someone resizing a photo for a public form almost never wants their home’s location going with it.
What I’d do differently
I’d measure from day one. I can tell you how the size search works, but I can’t yet give you a clean “a typical phone photo goes from X MB to Y KB” figure, because I didn’t set up a fixed set of test photos before building. That comes next, along with a before-and-after slider so you can see what the compression cost, batch renaming, watermarks, and background removal with a model that runs on your device.
Try it
- Image Tools: https://img.vivekbhange.tech
- More free tools, including Private PDF, which compresses PDFs to a target size the same way: https://vivekbhange.tech/tools/
- Source code: https://github.com/vivekbhange-hub/image-tools
If an image comes out wrong, or bigger than you expected, please open an issue.
Enjoyed this?
Written by Vivek Bhange, Full-Stack AI Engineer. See his work or work with me.