How image compression works
An image's file size comes down to three levers: format, quality, and resolution. Here's what each one actually does, and how this tool decides which to pull.
Lossy vs lossless
JPG and WebP are lossy: they throw away detail a viewer is unlikely to notice, like subtle color variation in a smooth gradient, to save space. PNG is lossless: every pixel is stored exactly, so it doesn't have a quality setting at all, only resolution affects its file size.
What quality actually changes
For JPG and WebP, quality controls how aggressively the encoder compresses each block of pixels. High quality keeps fine texture and sharp edges; low quality smooths detail away and can introduce visible blocky patches, especially around text or hard edges. This tool finds the highest quality that still fits your target by testing values with a binary search, checking the middle of the possible range, then narrowing in based on whether the result was too big or comfortably under, rather than scanning every quality level one by one.
Why resolution matters too
A 4000×3000 pixel photo has to compress far harder to hit 200 KB than the same photo resized to 1600×1200, because there's simply more pixel data to represent. When quality alone can't reach your target without looking noticeably degraded, this tool reduces the image's dimensions instead, since a smaller image at higher quality usually looks better than a full-size image crushed to very low quality.
Why format changes the outcome the most
Two images with identical pixels can differ by several times in file size purely based on format. WebP's compression is generally the most efficient of the three for photos, JPG is close behind and more universally compatible, and PNG is the odd one out, it can't lose quality at all, so shrinking it means shrinking its dimensions rather than adjusting how it's encoded.
Why this runs entirely in your browser
All of this, decoding your file, drawing it to a canvas, testing quality levels, and re-encoding, happens using your browser's built-in Canvas API in a background worker thread. Nothing is uploaded anywhere, which is also why the tool works offline once the page has loaded.
Ready to try it?
Try the compressor →