Image Compressor — JPG via DCT, PNG via DEFLATE, WebP via VP8
Image compression spans three fundamentally different algorithms depending on format. JPG (ITU-T T.81 / ISO/IEC 10918-1, 18 September 1992) uses lossy DCT + Huffman quantisation per Annex K — quality 1–100 maps to quantisation table scaling. PNG (W3C Recommendation 10 November 2003 / ISO/IEC 15948:2004) uses lossless DEFLATE (RFC 1951 Deutsch, May 1996, LZ77 + Huffman with 32 KB sliding window) — compression gain comes from filter selection (5 types per scanline) and zlib level, not pixel discarding. WebP (RFC 9649 Zern, Massimino & Alakuijala, Google LLC, November 2024) supports both lossy (VP8 keyframes per RFC 6386 Bankoski et al., November 2011) and lossless (LZ77 + Huffman/prefix coding + colour cache). This tool uses the widely-used browser-image-compression library (Donaldcwl, MIT licence): Canvas-based for JPG/WebP/BMP, UZIP-based DEFLATE for PNG, with Web Worker offloading via OffscreenCanvas when available.
How to compress an image
- Drop a JPG/PNG/WebP/BMP file onto the tool or click to browse — single file or batch.
- The tool detects format and routes to the appropriate pipeline (Canvas+JPG/WebP, UZIP+PNG).
- Adjust quality (effective for JPG/WebP — PNG is lossless regardless). 80–85 is the standard web sweet spot for photos.
- Review before/after sizes (typical: JPG 40–70% reduction, WebP 25–35% smaller than JPG, PNG 5–30% lossless gain), then download.
Common use cases
- Optimising mixed-format image library (JPG photos + PNG logos + WebP variants) before uploading to a CMS in batch.
- Reducing email attachment size below 10 MB / 25 MB limits without resizing — JPG quality 75 typically does the trick.
- Cutting Core Web Vitals (LCP) on image-heavy pages by re-encoding all hero images at quality 80–85.
- Trimming photo backups before cloud upload (Google Drive, Dropbox, iCloud) — typical 40–60% storage reduction with no visible quality loss.
Frequently asked questions
How does the compressor route different formats — JPG, PNG, WebP, BMP?
Uses the widely-used browser-image-compression library (Donaldcwl, MIT) which detects MIME type. JPGs/WebPs go through Canvas toBlob() per ITU-T T.81 / RFC 9649. PNGs bypass Canvas and use UZIP (JavaScript DEFLATE per RFC 1951) for lossless re-compression with optimised filter selection.
Does PNG compression work the same way as JPG and WebP compression?
No, fundamentally different. PNG (W3C 2nd Ed) is lossless by design — DEFLATE re-encoding only optimises filter selection + zlib level. Expected savings: 5–30% (vs JPG's 40–70%). For lossy PNG palette quantisation (up to 70% savings) you'd need libimagequant/pngquant.
What does the quality slider actually do for each format?
JPG: quality 1–100 maps to ITU-T T.81 Annex K Q-table scaling. 85–90 visually lossless; 75–85 web sweet spot. WebP: quality controls VP8 quantiser (Firefox 105+ supports quality=1.0 lossless). PNG: quality slider has NO effect — PNG is lossless regardless.
Will my image's EXIF metadata survive compression?
JPG: by default Canvas strips EXIF (JEITA CP-3451X / CIPA DC-X008-2019, Exif 2.32, May 2019); browser-image-compression has opt-in preserveExif flag. PNG: native PNG has no widely-supported EXIF chunk. WebP: supports EXIF chunk per RFC 9649 §2.7.1.5 but Canvas re-encoding strips it.
Does the compressor run my images in the cloud?
No. Local processing via WHATWG Canvas 2D Context (JPG/WebP) or UZIP (PNG), running in Web Worker thread when OffscreenCanvas available. No file leaves device — verifiable in DevTools Network tab (no upload requests fire).
How the compressor routes each format — and what the quality slider actually does
The browser-image-compression library detects MIME type and routes to the appropriate pipeline. For JPG: decode to pixels via Canvas → toBlob('image/jpeg', quality) → re-encode via the browser's built-in JPEG encoder using ITU-T T.81 Annex K quantisation tables. The quality slider (1–100) directly scales the Q-tables — higher quality = smaller quantisation steps = more DCT coefficients preserved = larger file. For WebP: same pipeline but toBlob('image/webp', quality) → VP8 keyframe encoding for lossy mode (Firefox 105+ also supports lossless via quality=1.0). For PNG: bypasses Canvas entirely (since Canvas's PNG output is unoptimised) and uses UZIP — a pure-JavaScript DEFLATE implementation by photopea — to re-encode losslessly with optimised filter selection and higher zlib compression level (typically 5–30% smaller than the source PNG, with zero pixel changes). Critical caveat: PNG-to-PNG compression is strictly lossless; the quality slider has NO effect on PNG output. Browser support asymmetry: JPG output works everywhere; WebP output requires libwebp WebAssembly polyfill in Safari (Safari does not support image/webp via canvas.toBlob as of 2026 — a long-standing WebKit limitation tracked at bugs.webkit.org). EXIF metadata: by default Canvas-based re-encoding strips JPEG APP1 EXIF (JEITA CP-3451X / CIPA DC-X008-2019, Exif 2.32, May 2019) — privacy benefit; browser-image-compression has an opt-in preserveExif flag.
- JPG re-encoding via ITU-T T.81 Annex K quantisation (quality 1–100 maps to Q-table scaling)
- PNG lossless re-compression via UZIP DEFLATE (RFC 1951) with optimised filter selection
- WebP re-encoding via VP8 (RFC 6386) for lossy or LZ77 + Huffman for lossless
- Real-time before/after size comparison with percentage savings
- Web Worker offloading via OffscreenCanvas when supported (non-blocking batch processing)
- EXIF metadata stripped by default for privacy (JEITA CP-3451X Exif 2.32) — opt-in preserveExif available
Free. No signup. No file uploads. Ads via AdSense (consent required).
Sources (5)
- Donald (Donaldcwl) (live). browser-image-compression. npm package v2.0.2 (github.com/Donaldcwl/browser-image-compression, MIT license) — widely-used JS image compressor: Canvas-based for JPG/WebP/BMP, UZIP-based DEFLATE for PNG; supports OffscreenCanvas + Web Worker.
- WHATWG (live). HTML Living Standard — Canvas 2D Context + HTMLCanvasElement.toBlob(). html.spec.whatwg.org/#2dcontext (toBlob('image/jpeg', quality) for JPG re-encoding, toBlob('image/webp', quality) for WebP — universal Chrome/Edge/Firefox 96+, Safari WebP needs polyfill).
- ITU-T (CCITT) Study Group VIII & ISO/IEC JTC 1/SC 29/WG 10 (JPEG) (1992). Information technology — Digital compression and coding of continuous-tone still images. ITU-T Recommendation T.81 (18 September 1992) / ISO/IEC 10918-1:1994 — DCT + Huffman quantisation per Annex K underlies JPG quality slider.
- W3C (PNG Working Group) (2003). Portable Network Graphics (PNG) Specification (Second Edition). W3C Recommendation 10 November 2003 / ISO/IEC 15948:2004 — PNG uses RFC 1951 DEFLATE (LZ77 + Huffman); browser-image-compression's UZIP path re-applies DEFLATE losslessly with optimised filter selection.
- Zern, J., Massimino, P., & Alakuijala, J. (Google LLC) (2024). WebP Image Format. RFC 9649, IETF (November 2024) — WebP container; lossy mode VP8 (RFC 6386 Bankoski et al., Nov 2011) accepts quality 1–100; lossless mode preserves pixels exactly.
These are the W3C, ISO/IEC, ITU-T, and IETF specifications the tool implements or builds on. Locate them on w3.org, iso.org, itu.int, or datatracker.ietf.org.
Related guides
- EXIF Metadata — What It Leaks and How to Strip ItYour photos probably contain GPS coordinates, camera serial numbers, and timestamps. Here's exactly what EXIF exposes and how to strip it safely.
- Image Compression for Core Web Vitals — What Actually Moves the NeedleThe image optimization changes that actually improve LCP, CLS, and INP — with real numbers. Skip the myths, ship the ones that move scores.
- How to Remove Image Backgrounds Without Quality LossA practical guide to removing image backgrounds cleanly — edge handling, alpha channels, PNG vs WebP output, and when AI tools actually help versus hurt.
- Responsive Images with srcset — Explained Properlysrcset and sizes without the confusion. How the browser actually picks an image, what w vs x descriptors do, and the patterns that work in production.