ImageMar 11, 2026 · Updated Oct 13, 2026 · 3 min read

How to Compress Images for the Web Without Losing Quality

How much each JPEG quality step saves, measured on 24 standard test photos, how WebP and AVIF compare at equal quality, and why resizing first matters more than any setting.

Computer, macbook, tablet — illustrating How to Compress Images for the Web Without Losing Quality
🖼️
Try the Image Compressor
Free, no signup
→
DG
Derek Giordano
Designer & Developer
In this guide
01Lossy vs Lossless02What the Quality Setting Buys03Resize Before You Compress04In Practice

Lossy vs Lossless

Lossy compression (JPEG, lossy WebP, AVIF) discards detail; lossless (PNG, lossless WebP) keeps every pixel. Photos almost always go lossy; screenshots, UI and anything with small text are usually smaller and sharper as lossless WebP.

What the Quality Setting Buys

We saved the 24 photos of the Kodak test suite (768×512, lossless originals) as JPEG at four quality settings and measured file size and similarity to the original (SSIM on luminance, 1.0 = identical; October 13, 2026):

SettingMedian sizeMedian SSIM
Lossless PNG (original)606 KB1.0
JPEG q95155 KB0.987
JPEG q8582 KB0.965
JPEG q7560 KB0.948
JPEG q6045 KB0.929

Going from q95 to q85 halves the file; q85 to q75 saves another 27%. Below about q75 the savings shrink while quality keeps falling. Most sites settle between 75 and 85 and check the busiest image by eye, because SSIM does not capture every artifact. At equal SSIM, WebP files were a median 26-27% smaller than JPEG and AVIF 37-38% smaller.

Resize Before You Compress

Pixel count matters more than any quality setting. A 4000×3000 photo shown at 800×600 sends 25 times the pixels needed (96% are thrown away by the browser). Export at the largest size it is displayed, or at twice that for high-density screens, and let srcset and sizes pick the right file. Without attributes or CSS sizing, also give every image width and height so the browser reserves space before it loads.

In Practice

For one-off images, the Image Compressor resizes and re-encodes in your browser: JPEG stays JPEG, PNG and WebP become WebP with transparency kept, and if the new file is not smaller it gives you the original back (tested on five files when we rebuilt it). For a site, automate it in the build (Sharp, libvips or Squoosh CLI) or through an image CDN, and serve AVIF or WebP with a JPEG fallback.

Frequently Asked Questions

What is the best image quality setting for web?+
For JPEG and WebP, usually 75-85. On 24 Kodak test photos JPEG q85 was a median 82 KB at SSIM 0.965 and q75 60 KB at 0.948, against 155 KB for q95. Check your busiest image by eye before settling lower.
Should I use WebP or JPEG?+
WebP, with JPEG as a fallback if you need one. At equal SSIM it was a median 26% smaller than JPEG on our 24 test photos, and all current browsers display it.
How much can image compression reduce file size?+
A lot, mostly from resizing: a 4000×3000 photo shown at 800×600 carries 25 times the pixels it needs. Re-encoding then saves more: on our test photos JPEG q85 was about a seventh of the lossless original, and WebP or AVIF cut another quarter to three-eighths.
Try it yourself

Use the Image Compressor — free, no signup required.

⚡ Open Image Compressor
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.
⚡ Try the free Image Upscaler →
⚡ Try the free CSS Sprite Sheet Generator →