Drop in your own photo, squeeze it with four real encoders, slide between them at pixel level and see the error they leave behind – then find which format gives the smallest file at the same measured quality
Quick Answer:Compare formats at the same measured quality, not the same "quality" number – each encoder uses its own scale. For typical photos WebP is about 25–34 % smaller than JPEG at the same SSIM (Google's WebP study), and AVIF is usually smaller again, most of all on smooth skies and gradients. MozJPEG keeps full JPEG compatibility and is tuned for how pictures look rather than for SSIM, so by SSIM it wins on some images and loses on fine texture. SSIM ≥ 0.98 is hard to tell from the original at normal size; PSNR is 10·log10(255² ÷ MSE) dB. Your result depends on the picture – measure it below.
A
--
B
--
Encoding…
Drag across the image to compare · zoom to see the pixels
Fit: drag moves the divider · zoomed: drag pans the picture
Same quality, smallest file
Measuring…
The lab encodes a smaller copy of the image at 10 quality steps in every format and reads off the file size at your target quality.
Format
Size
vs JPEG
--
Rate–distortion · quality against bits per pixel (up and left is better)
--
The two sides
The test images are drawn by the page itself. Use "Use your own image" above, or drop a file on the picture.
Every measured file
The sweep behind the chart, on a copy of the image at most 512 px wide. Sizes scale roughly with the pixel count.
Quality
JPEG
MozJPEG
WebP
AVIF
Each cell: file size · SSIM. Quality numbers are each encoder's own scale.
What to look for
JPEG breaks into 8×8 blocks and rings around sharp edges and text. WebP smears fine texture and shifts colours on red/blue edges (4:2:0 colour). AVIF stays clean on skies and gradients but can wash out grass, hair and film grain. Zoom to 400 % and switch to the error heatmap to see where each one spends its bits.
Model assumptions – what this model leaves out
SSIM and PSNR are not your eyes. Both are standard, repeatable metrics, but they miss some things people notice (colour shifts, smoothed-away texture) and overrate others. Newer metrics such as SSIMULACRA 2 or Butteraugli track perception better and are not computed here.
Luma-only SSIM, measured at the working size. SSIM uses the 11 × 11 Gaussian window of Wang et al. (2004) on the brightness channel; colour errors only show up in PSNR. Large images are scaled to 1,600 px on the long side before testing, and the format sweep uses a 512 px copy, so absolute file sizes differ from your full-size originals.
Encoder versions and settings. JPEG uses your browser's own encoder (different browsers give different sizes); MozJPEG 4 (@jsquash/jpeg 1.6.0), libwebp (@jsquash/webp 1.5.0, method 4) and libavif (@jsquash/avif 2.1.1, speed 6, 4:2:0) run as WebAssembly with default settings. Slower AVIF/WebP presets, 4:4:4 colour or JPEG XL would change the numbers.
Transparency and metadata. Transparent areas are flattened onto white, and no EXIF/ICC data is written, so files are slightly smaller than many real exports.
Decoding is not measured. AVIF takes longer to encode and decode than JPEG; on old devices and some email clients AVIF or WebP may not display at all.
How the Image Compression Lab – JPEG vs WebP vs AVIF works
Your image (or one of the test pictures the page draws itself) is flattened onto white and scaled to at most 1,600 px on the long side. Side A and side B are each encoded with the chosen encoder and quality, decoded again by the browser, and compared pixel by pixel with the original.
Quality is measured with PSNR over the red, green and blue channels and with SSIM (Wang et al. 2004: 11 × 11 Gaussian window, σ = 1.5, K1 = 0.01, K2 = 0.03) on the brightness channel. The error heatmap shows the absolute difference per pixel; the SSIM map shows where structure was lost.
For the fair comparison a 512 px copy is encoded at ten quality steps in every format. The file size at your target SSIM is read off each curve by interpolating between the two steps around it (in log size), which is how codec studies compare formats at equal quality.
Two encodings of the same 1,000 × 500 px photo: one is 50 kB, and in another every pixel is off by exactly one level.
The 50 kB file uses 50,000 × 8 ÷ 500,000 = 0.8 bits per pixel, versus 24 for the uncompressed image – a 30 : 1 reduction.
An error of 1 level everywhere gives MSE = 1, so PSNR = 10·log10(65,025) = 48.1 dB.
If the sweep measures a format at SSIM 0.95 for 2,000 bytes and 0.98 for 4,000 bytes, the size at SSIM 0.965 is read off half-way in log size: √(2,000 × 4,000) = 2,828 bytes.
Result: Compare formats at the same SSIM (or PSNR), not the same quality number – each encoder’s scale is different.
Assumptions and limits
SSIM and PSNR are standard but not perceptual ground truth; colour errors only appear in PSNR. Measurements use the working size, not your full-resolution file.
JPEG uses the browser’s own encoder; MozJPEG (@jsquash/jpeg 1.6.0), WebP (@jsquash/webp 1.5.0) and AVIF (@jsquash/avif 2.1.1, speed 6) run as WebAssembly with default settings. Images never leave the device.
Checked: PSNR of a one-level error 48.131 dB (exact 48.131); SSIM of identical images 1; SSIM after a +20 brightness shift 0.986099, equal to the analytic window formula; SSIM of a noisy image 0.747346, equal to an independent brute-force 2D-window implementation; size interpolation 2,828.4 bytes as above. Real encoders at SSIM 0.95: WebP 25 % (landscape) and 30 % (texture) smaller than browser JPEG, in line with Google’s WebP study (25–34 % at equal SSIM); AVIF 56–57 % smaller. MozJPEG, tuned for perceived rather than SSIM quality, was 7–37 % smaller on the landscape, gradient and screenshot but larger on fine texture.
Sources
Wang Z, Bovik AC, Sheikh HR, Simoncelli EP (2004). Image quality assessment: from error visibility to structural similarity. IEEE TIP 13(4), 600–612
Frequently Asked Questions About Image Compression Formats
Is AVIF smaller than WebP and JPEG at the same quality?
Usually, for photos. Google's WebP study found WebP files 25–34 % smaller than JPEG at the same SSIM, and AVIF is typically smaller again, especially at low and medium quality. The gap depends on the picture: smooth gradients and skies gain the most, very fine texture and sharp text the least. This lab measures it for your own image instead of quoting an average.
Why can't I compare quality settings across formats?
Each encoder uses its own scale. JPEG quality 80, WebP quality 80 and AVIF quality 80 are different amounts of compression, so comparing files at the same number is meaningless. The fair comparison is file size at the same measured quality – for example the same SSIM – which is what the rate–distortion chart and the 'same quality' table show.
What is a good SSIM or PSNR for web images?
SSIM runs from 0 to 1, where 1 means identical. Around 0.98 and above most people cannot see a difference at normal size; 0.95 is visibly softer on close inspection; below 0.90 artefacts are obvious. For PSNR on 8-bit images, roughly 40 dB and above is very good and 30–35 dB is typical of strong web compression. Both are guides – always look at the image too.
Is my image uploaded anywhere?
No. The image is decoded, compressed and measured entirely in your browser. The encoders (MozJPEG, libwebp and libavif compiled to WebAssembly) are downloaded from a public CDN, but your picture never leaves your device.