Image Compressor — JPG, PNG, and WebP
Shrink JPG, PNG, and WebP files by 50–90% — fully inside your browser, no signup, no upload. Pick a quality preset, batch up to 50 images, optionally resize the longest side, and download. Sources cited.
How it works
Modern browsers ship with built-in JPEG, WebP, and PNG encoders reachable through one Web API: HTMLCanvasElement.toBlob(callback, mimeType, quality). The compressor draws your image into an off-screen canvas, asks the browser to encode it at the chosen quality, and offers the resulting Blob as a download via an object URL. No part of the file leaves the page — you can watch your browser's Network tab while using the tool to confirm.
The encoded byte count depends on three things: pixel count, encoder family, and quality setting. Pixel count is a direct multiplier (twice the pixels, roughly twice the bytes). The encoder family sets a baseline — WebP averages 25–34% smaller than JPEG at equivalent perceptual quality, per Google's published WebP study. Quality moves you along a non-linear curve: between q=90 and q=100 the size doubles for almost no visible improvement; between q=40 and q=60 the size halves for noticeable quality gain.
The size estimator on the tool uses an empirical bits-per-pixel curve fitted to JPEG-corpus measurements and the WebP study numbers:
bpp_jpeg(q) = 0.05 + 1.4 × (q / 100)^2.5 bpp_webp(q) = bpp_jpeg(q) × 0.70 bytes = (pixels × bpp) / 8 + ~1 KB header overhead
The 0.05 term is the asymptotic floor: even at quality 0 a JPEG file needs that many bits per pixel for the quantised DCT coefficients and Huffman tables. The 2.5 exponent captures the steep growth in size between quality 60 and 90 — the region where most visible detail is preserved. The estimator is cross-checked against a second formula that linearly interpolates a five-point lookup table; the two land within ±5% on every quality between 1 and 100. The page above runs the estimator on the first queued image; the actual encoder may differ by ±10–20% depending on image content (textured photos encode larger than flat-colour graphics at the same quality).
For each image the tool does five deterministic things:
- Validate. Confirms the file is JPG, PNG, or WebP and within the size cap of 50.0 MB. Rejected files leave a specific reason in the queue rather than failing silently.
- Decode. Loads the image into an
HTMLImageElementso the browser uses its native decoder. Natural width and height are read fromnaturalWidth/naturalHeight. - Resolve dimensions. When a resize preset is selected, the longest side is scaled down to fit, preserving aspect ratio to the nearest pixel. Images are never scaled up.
- Re-draw. The image is painted onto a new canvas at the target size with
imageSmoothingQuality = "high"(a bicubic-class resampler in current browsers). For JPEG output, the canvas is pre-filled with white so transparent source pixels don't turn black. - Encode & download.
canvas.toBlobproduces the compressed Blob with the requested MIME type and quality. The Blob is wrapped in an object URL and offered as a download with the matching file extension.
Worked examples
Quality presets at a glance
Each preset chip on the tool maps to a quality value on the 0–100 scale that canvas.toBlob accepts. The same q-value is read by every browser's JPEG and WebP encoder, so the same preset behaves consistently across Chrome, Edge, Firefox, and Safari.
| Preset | Quality | Typical use |
|---|---|---|
| Max | 92 | Visually lossless on JPEG. ~30% smaller than the source. |
| High | 82 | Good for hero photos and product shots. ~50% smaller. |
| Balanced | 70 | Default. Sharp on screen; ~65% smaller than the source. |
| Compact | 55 | Strong compression for chat / email. Light artifacts at 100% zoom. |
| Aggressive | 40 | Smallest viable size. Visible blockiness on flat colour areas. |
Frequently asked questions
Sources & references
- MDN — HTMLCanvasElement.toBlob (browser-native JPEG/WebP/PNG encoder)
- MDN — CanvasRenderingContext2D.drawImage (resampling and alpha handling)
- Google — WebP Compression Study (25–34% smaller than JPEG at equivalent quality)
- ITU-T T.81 — JPEG specification (DCT, quantisation, Huffman coding)
- web.dev — Use optimized images (image size vs perceptual quality guidance)
The size estimator and the cited compression-vs-quality relationships were last cross-checked against the above sources on 2026-05-11. The page is reviewed when browsers ship a new lossy encoder generation or when Google refreshes the WebP study.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.