How the image compressor works
The browser decodes each image, redraws it at its original dimensions, and encodes a new file at the selected quality. Target-size mode searches progressively lower quality values for the closest usable JPEG or WebP result.
output bytes = browser encoder(image, format, quality)Target-size mode tests at most seven quality levels and accepts a result within five percent when possible.
Compress a 1.8 MB JPEG toward a 300 KB target
The tool first encodes at the selected maximum quality. If that result is too large, it tests lower quality levels, keeps the closest result below the target when available, and warns when the requested size cannot be reached.
Using the processed image
Keep the exported dimensions, format, transparency, and compression level appropriate for where the image will be used.
canvas.toBlob(handleBlob, "image/jpeg", 0.8);canvas.toBlob(handleBlob, "image/webp", 0.8);Using the result accurately
Compare detail around text, hair, gradients, and high-contrast edges rather than relying only on byte size. WebP is often useful for web delivery, while JPEG remains broadly compatible for opaque photographs.
A requested byte size is not guaranteed because image complexity and browser encoders differ. PNG quality is lossless and does not use the quality slider, and re-encoding can occasionally create a file larger than its source.
References: MDN HTMLCanvasElement toBlob().