ImageApr 27, 2026 · Updated Oct 14, 2026 · 5 min read

How to Optimize Images for Web Without Losing Quality (2026)

Resize first, then compress: one camera photo went from 2,466 KB to 281 KB by resizing alone. We measured JPEG quality settings, WebP and AVIF at equal SSIM on eight test photos, and what still matters when the browser loads the file.

▣
Try the Image Compressor
Free, no signup
→
DG
Derek Giordano
Designer & Developer
In this guide
01Where the Bytes Go02Resize First, Then Compress03Quality Settings, Measured04WebP and AVIF at the Same Quality05Loading the Image You Kept06Doing It in the Browser

Where the Bytes Go

Images are still the heaviest part of most pages. HTTP Archive's 2024 Web Almanac measured median image bytes of 1,054 KB on desktop homepages and 900 KB on mobile ones, and 442 KB and 348 KB on inner pages. Dornauer and Felderer (2023, found through alphaXiv) put images at about 41% of the median page's request size in July 2023 (1,010.6 KB of 2,449.4 KB). Their crawl of 58,057 popular sites also showed how slowly formats change: of 2.66 million images, 33.2% were JPEG, 32.4% PNG, 19.9% SVG, 11.3% GIF and 3.0% WebP, with AVIF and every other format together under 0.1%.

So the easy wins are still on the table for most sites. We measured where they come from, in order of size.

Resize First, Then Compress

A phone photo or camera file is usually several times wider than any slot on a page. We took one 5,363 × 3,576 photo from Wikimedia Commons (Vihorlat (v zime) 046, CC BY-SA 4.0) and saved it at four widths and two quality settings with Pillow 12.1:

WidthJPEG q85JPEG q60WebP q85WebP q60
5,363 px (original size)2,466 KB1,319 KB1,490 KB709 KB
3,200 px1,018 KB541 KB741 KB358 KB
1,600 px281 KB149 KB220 KB108 KB
800 px76 KB42 KB61 KB30 KB

Dropping the quality from 85 to 60 at full size saved 47%. Resizing to 1,600 px at quality 85 saved 89%, and the result still looks sharp on a 1,600 px slot. Resize to the largest size the layout will actually show, then use srcset and sizes so phones fetch a smaller file than desktops. The Bulk Image Resizer resamples with a Lanczos-3 filter and never enlarges a smaller image.

Quality Settings, Measured

Quality numbers are encoder settings, not a percentage of anything. To see what they buy, we encoded eight photos from the Kodak Lossless True Color Image Suite (768 × 512 each) and scored every result against the original with SSIM, a structural-similarity measure where 1.0 means identical. Medians across the eight:

JPEG qualityMedian sizeMedian SSIM
6039.7 KB0.939
7047.3 KB0.950
7552.1 KB0.957
8059.9 KB0.964
8571.0 KB0.970
9090.5 KB0.979
95133.0 KB0.989

The curve bends sharply at the top. Going from quality 85 to 95 added 87% to the file for 0.019 more SSIM; going from 75 to 85 added 36% for 0.013. That is why 75 to 85 is the usual range for photos. Below that, check the result on the image itself: smooth gradients such as skies band first, and text in a photo blurs before faces do. SSIM is a rough guide rather than a verdict; a 2025 evaluation of quality metrics for high-fidelity compression from the University of Lisbon, the University of Konstanz and Cloudinary (also on alphaXiv) is about exactly that gap.

The numbers also do not carry across formats. AVIF at quality 60 scored 0.970, the same as JPEG at 85, so copying one quality value into a different encoder gives a different result.

WebP and AVIF at the Same Quality

For each of the eight photos we found the WebP and AVIF file that matched the JPEG quality 85 SSIM and compared sizes:

FormatMedian saving vs JPEG q85Range across 8 photosvs JPEG q75
WebP (libwebp 1.6.0)31%13% to 36%30%
AVIF (libavif 1.3.0)42%34% to 51%44%
PNG (lossless)8 times larger

Google's own figure for WebP is 25% to 34% smaller than JPEG at equal SSIM, which matches what we saw. In browsers, Dornauer and Felderer re-encoded a test page's images to the same SSIM (0.95) and measured page load time across Chrome, Edge, Safari, Opera and Firefox: WebP loaded 1.21 times faster than JPEG and AVIF 1.15 times faster, while first contentful paint did not change significantly. MDN's image format guide lists AVIF in Chrome 85, Firefox 93, Safari 16.1 and Edge 121, so both formats are safe to serve with a fallback.

<picture>
  <source type="image/avif" srcset="hero-1600.avif 1600w, hero-800.avif 800w" sizes="100vw">
  <source type="image/webp" srcset="hero-1600.webp 1600w, hero-800.webp 800w" sizes="100vw">
  <img src="hero-1600.jpg" width="1600" height="900" alt="Ridge above the clouds at dawn"
       fetchpriority="high">
</picture>

PNG is the right choice for screenshots, logos and anything with sharp edges or transparency, not for photos: on our eight photos the lossless PNG was a median 8 times the size of the JPEG at quality 85.

Loading the Image You Kept

The width and height attributes let the browser reserve the space before the file arrives; in our aspect-ratio tests that meant 225 px held in place instead of a 0 px box that jumps. Add loading="lazy" to images below the first screen, and never to the hero, which is usually the Largest Contentful Paint element. For the hero, fetchpriority="high" asks the browser to fetch it before other images; MDN's compatibility data lists it in Chrome and Edge 101, Safari 17.2 and Firefox 132.

Doing It in the Browser

Our Image Compressor works on your device, without uploading anything. Its Auto mode keeps a JPEG as JPEG and turns PNG, WebP and GIF files into WebP, which keeps transparency. If a re-encode at the same size would not be smaller, it hands back the original with a note rather than a bigger file. The Image Converter changes formats and checks each output file's signature before offering it. For format choices beyond photos, see our guide to choosing an image format.

Frequently Asked Questions

Is WebP better than JPEG?+
For photos on the web, usually. At equal SSIM, WebP files were a median 31% smaller than JPEG quality 85 across our eight test photos (13% to 36%), and every current browser decodes WebP. Keep a JPEG copy for software that cannot open WebP.
Does this tool upload my images?+
No. The Image Compressor decodes and re-encodes images in your browser with the Canvas API, so the files never leave your device.
What about AVIF?+
At equal SSIM our AVIF files were a median 42% smaller than JPEG quality 85 (34% to 51%). MDN lists AVIF in Chrome 85, Firefox 93, Safari 16.1 and Edge 121, so serve it in a picture element with a WebP or JPEG fallback. Quality numbers are not comparable between encoders: AVIF at 60 matched JPEG at 85 in our test.
Try it yourself

Use the Image Compressor — free, no signup required.

⚡ Open Image Compressor