Compression is not one operation. It is a family of trade-offs, and the right choice depends on where the image will be used. This guide explains what actually happens when you compress an image in a browser, so you can read the before/after numbers instead of guessing.
Two kinds of compression
Lossless compression stores the same pixels in fewer bytes by finding repetition and encoding it more efficiently. A PNG optimized losslessly looks identical to the original. The savings depend entirely on the image content.
Lossy compression discards information the viewer is unlikely to notice. JPEG and lossy WebP work this way. You control the degree with a quality setting. Lower quality means a smaller file and more visible artefacts.
There is no universal “best” quality. A product photo on a store page and a thumbnail in a chat message have different tolerances.
Resize before you compress
Pixel count is the dominant factor in file size. An image that is 4000 pixels wide but displayed at 800 pixels is carrying four times more detail than the screen can show in each direction. Resizing first usually produces a much larger saving than nudging a quality slider.
A practical order:
- Decide the largest size the image will be displayed at.
- Resize to roughly twice that width for high-density screens.
- Compress to a file size that fits your page budget.
Why the output can be larger
Compression tools are not magic. Re-encoding an already optimized JPEG at a high quality can produce a bigger file. Browser canvas encoders also differ from dedicated image optimizers: a PNG exported through canvas may be less efficient than the original.
If the compressed file is larger, the honest answer is to keep the original. A tool that always reports success is hiding useful information. The compressor on this site shows before and after sizes and warns you when the result grows.
What gets lost
Canvas-based re-encoding has side effects beyond visible quality:
- EXIF metadata is removed, including camera details and GPS coordinates.
- Color profiles may be dropped, which can shift saturated colors slightly.
- Transparency is flattened if you export to JPEG.
- Animation is discarded unless the format supports it and the encoder preserves it, which these tools do not claim.
For privacy-sensitive photos, stripping metadata is often a benefit. For print or archival work, keep the original file.
How to judge quality
Do not rely on the file size alone. Compare at the size the image will actually be viewed:
- Zoom to 100% and inspect edges, text and faces.
- Look at smooth gradients for banding.
- Check dark areas for blocky artefacts.
- Verify that transparency and orientation survived.
A small file that looks wrong is not a successful compression. A slightly larger file that preserves the detail you need is.
Use the image compressor for quality and size comparison, and the image resizer when dimensions are the real problem.