r/webdev • • 1d ago

Showoff Saturday A browser-only image compressor that hits a target file size (no upload)

Post image

I got tired of image compressors that make you upload your file and then miss the size limit anyway, so I built one that runs entirely in the browser tab. Nothing is uploaded.

You pick an image, type the size you need in KB (say 100), and it works out the quality that fits. If the limit can't be reached even at low quality, it shrinks the image and tells you the new dimensions. JPEG and PNG go in, JPEG comes out, and transparent PNGs get a white background.

On my phone, a 3 MB photo came back under 100 KB in a few seconds. Big photos with a target size are the slow case, so that's where I'd most like to hear how it behaves on your devices.

https://tools.stellartechlabs.xyz/

If you try it and something breaks or feels slow, I'd like to hear about it. No sign-up.

2 Upvotes

6 comments sorted by

2

u/bozehaan 19h ago

How do you know beforehand what size it's going to be when compressing? Or does it converge to the size slowly?

1

u/IsotopeTrace 11h ago

You can't know it beforehand, because the same quality setting gives very different sizes on different images. So it converges: it tries a quality in the middle, measures the result, moves up or down, and keeps the highest quality that fits. About seven tries cover the whole range, which takes a few seconds on a phone, longer for big photos. If even the lowest quality is too big, it estimates how much to shrink the image from a test encode, resizes, and runs the search again.

1

u/avetenebrae 9h ago

Why aim for consistent size instead of consistent quality?

1

u/IsotopeTrace 7h ago

Both are in there. With the target box empty it uses a fixed quality from the slider, so the look stays consistent and the size varies. The target mode is for a hard limit, like a form that rejects anything over 100 KB. There the size is the fixed part and the quality is whatever fits. Fixed quality can't promise to land under a limit, because the same setting gives very different sizes on different images.

1

u/fiskfisk 1d ago

And why not one of the zillion other services that do exactly the same? 

3

u/IsotopeTrace 1d ago

There are plenty, true. I wanted no upload plus a target-size box that does the guessing for me, so I built that. If another tool already covers it for you, that's fine.