Developer Tools

AVIF vs WebP: Real File Sizes, Quality and When to Use Each

AVIF vs WebP benchmarked: matched-SSIM file sizes for photos and a UI screenshot, encode times, 2026 browser support, and when to use each format.

TechLogHub Editorial
December 4, 2026
14 min read
0 views

Share Article

TechLogHub cover: one photo encoded as JPEG, WebP and AVIF at equal SSIM, with AVIF the smallest file

AVIF vs WebP: Real File Sizes, Quality and When to Use Each

Quick answer: AVIF makes smaller photos than WebP. In our test, at the same SSIM score as a quality-80 JPEG, AVIF files were 42–53% smaller than the JPEG and WebP files were 20–35% smaller. The cost is encode time: AVIF took roughly 5.5–8× longer than WebP. Both formats now load in more than 96% of browsers. Use AVIF for photos and hero images that you encode once and serve many times. Use WebP when you have to encode fast or on demand, and use lossless WebP for screenshots and UI captures. Keep a JPEG or PNG fallback in <picture>.

Most "AVIF vs WebP" articles repeat the same two marketing figures and stop there. This one runs the encoders. We encoded four images (three photos and one dark-mode dashboard screenshot) with Pillow, measured each result against the original, and matched quality across formats instead of comparing quality numbers that mean different things in each encoder. The short version: AVIF wins on bytes, WebP wins on speed and predictability, and the screenshot case breaks the usual advice in an interesting way.

If you only need a converted file, our free image format converter does PNG, JPEG, WebP and AVIF in the browser. If you care which one to ship, and at what quality, read on.

Where the two formats stand in December 2026

Browser support is no longer the deciding factor. caniuse lists AVIF at 96.71% global usage (October 2026 data): Chrome since 85, Firefox since 93, Edge since 121, and full Safari support since 16.4 (16.1–16.3 is marked partial). WebP is at 97.32%, with Chrome since 32, Firefox since 65, Edge since 18 and full Safari support since 16.0. MDN adds that older WebP support in Safari depends on the macOS version as well as the Safari version. That matters if your analytics show a long tail of old Macs.

Google Search indexes both. The Google Images best-practices page (updated 2026-03-02) lists the supported formats as BMP, GIF, JPEG, PNG, WebP, SVG and AVIF. JPEG XL is not on that list. Choosing AVIF over WebP costs you nothing in image search.

The format specs are mature too. The AV1 Image File Format specification is at v1.2.0, an AOM final deliverable dated 16 October 2025. Tooling has caught up as well. Since Pillow 11.3.0, AVIF read and write support ships inside Pillow's wheels, with libaom as the encoder and dav1d as the decoder (Windows ARM64 and iOS wheels are excluded). For Python shops, AVIF no longer needs a plugin or a custom libavif build.

PropertyAVIFWebP
Global browser support (caniuse, Oct 2026)96.71%97.32%
Max dimensions (MDN)2,147,483,647 × 2,147,483,64716,383 × 16,383
TransparencyYesYes
AnimationYes (Firefox from 113)Yes
HDR / wide gamutYesNot listed by MDN
Progressive renderingNoNo
Vendor size claim~50% smaller than JPEG (MDN)25–34% smaller than JPEG at equal SSIM; lossless 26% smaller than PNG (Google)
Pillow default quality75 (speed 6, 4:2:0)80 (method 4)

The 16,383-pixel limit on WebP rarely matters for web images, but it does catch out people generating long full-page screenshots or tall infographics. AVIF has no practical dimension limit. Neither format renders progressively, so on a slow connection both appear all at once instead of sharpening gradually the way a progressive JPEG does. If your Open Graph images or hero banners are large, that is a real perceived-performance difference compared with progressive JPEG.

Our benchmark: matched quality, not matched settings

The most common mistake in format comparisons is to set "quality 80" in each encoder and compare file sizes. Quality numbers are encoder-specific scales. WebP at 80 and AVIF at 80 are not the same visual quality, and neither equals JPEG at 80. To compare fairly, we fixed a target and searched for the lowest setting in each format that reached it.

Method

  • Images: three standard photos from scikit-image's sample data (astronaut 512×512, coffee 600×400, chelsea the cat 451×300), plus a 1280×800 dark dashboard screenshot we rendered with Playwright: sidebar, KPI cards, a gradient card and a 14-row table with monospace commit hashes.
  • Target: the SSIM score of a quality-80 JPEG of each image. SSIM was computed with scikit-image 0.26.0 against the lossless original, across all three colour channels.
  • Search: for WebP (method 4) and AVIF (speed 6, Pillow's default), we stepped quality up in increments of 2 and kept the first setting whose SSIM met or beat the JPEG.
  • Environment: Pillow 13.0.0 on Python 3.13.18, on a 2-vCPU Intel Xeon at 2.10 GHz. Encode times are single runs of Pillow's save(). Treat them as ratios, not absolutes.

The core of the script is short enough to reuse:

from PIL import Image
from skimage.metrics import structural_similarity as ssim
import io, numpy as np

def encode(im, fmt, **kw):
    buf = io.BytesIO(); im.save(buf, fmt, **kw); return buf.getvalue()

def score(orig, data):
    dec = np.asarray(Image.open(io.BytesIO(data)).convert("RGB"))
    return ssim(orig, dec, channel_axis=2, data_range=255)

im = Image.open("astronaut.png").convert("RGB"); orig = np.asarray(im)
target = score(orig, encode(im, "JPEG", quality=80))
for q in range(20, 101, 2):
    data = encode(im, "AVIF", quality=q, speed=6)
    if score(orig, data) >= target:
        print("AVIF", q, len(data)); break

Results: photos

ImageJPEG q80WebP (matched)AVIF (matched)
astronaut 512×512 (PNG 441,087 B)45,960 B · SSIM 0.9458q80 · 31,724 B · −31%q60 · 22,098 B · −52%
coffee 600×400 (PNG 461,327 B)48,001 B · SSIM 0.9190q74 · 31,140 B · −35%q56 · 22,587 B · −53%
chelsea 451×300 (PNG 225,801 B)23,693 B · SSIM 0.9552q82 · 18,870 B · −20%q62 · 13,786 B · −42%

The photo numbers land close to the vendor claims. WebP saved 20–35% against JPEG (Google says 25–34%), and AVIF saved 42–53% (MDN says about 50%). Against WebP, AVIF was another 27–30% smaller on every photo. For photographic content, that is a consistent, repeatable win.

Look at the quality column too. To match the same JPEG, WebP needed anywhere from q74 to q82, and AVIF needed q56 to q62. There is no universal "WebP quality that equals JPEG 80". It depends on the image. If you run a pipeline at one fixed quality, some images will be over-compressed and others will waste bytes. Content-aware quality selection (search to a target metric, as above) is worth building once you serve images at scale.

Results: encode time

ImageJPEG q80WebP matchedAVIF matched (speed 6)
astronaut4.5 ms27.5 ms180.1 ms
coffee1.6 ms32.2 ms196.6 ms
chelsea0.6 ms15.8 ms88.3 ms
dashboard 1280×8002.5 ms61.0 ms479.0 ms

This is the real price of AVIF. At Pillow's default speed, AVIF took roughly 5.5–8× longer than WebP and 40–190× longer than JPEG on the same images. For a static site build that runs once, nobody cares. For an image CDN or an upload endpoint that transcodes on request, half a second of CPU per 1280×800 image is a capacity-planning line item. Raising the AVIF speed setting toward 10 trades some of the size advantage back for time. Measure on your own images before you pick a value.

The screenshot surprise: lossless WebP beats everything

Our dashboard screenshot behaved completely differently from the photos. Here is the full picture:

Encoding of the 1280×800 dashboardSizeSSIMNotes
PNG (Playwright output)141,937 B1.0Lossless
PNG, Pillow optimize=True106,717 B1.0Lossless
JPEG q8086,658 B0.9783Ringing around text
WebP lossless (method 6)27,704 B1.0Bit-exact, 74% smaller than optimized PNG
WebP q36 (matched to JPEG SSIM)24,220 B0.9787Only 13% smaller than lossless WebP
AVIF q24 (matched to JPEG SSIM)11,007 B0.9816Visible smearing next to text
AVIF q75 (Pillow default)21,832 B0.9930Clean at normal zoom
AVIF q100, 4:4:470,958 B0.9980Not lossless: still below 1.0

Two things stand out. First, lossless WebP produced a pixel-perfect file a quarter the size of an optimized PNG. UI captures have large flat areas and repeated patterns, which is exactly what WebP's lossless mode is built for. The lossy WebP that matched JPEG's SSIM was only 13% smaller than that lossless file, so for screenshots there is little reason to accept lossy artefacts at all.

Second, SSIM lied about AVIF. AVIF at q24 had the highest SSIM of the lossy options, yet when we zoomed 4× into the commit-hash table, there were clear blotches and smearing in the dark background beside the text, where the JPEG and WebP crops were clean. SSIM averages structure over the whole image. A few damaged pixels around thin text barely move the score, but they are exactly where a reader's eyes go. This is the main limitation of metric-driven pipelines. For text-heavy images, check crops by eye or use a perceptual metric tuned for that content, and set a quality floor.

Practical rule from this test: photos → AVIF, screenshots and UI → lossless WebP. If the screenshot must be lossy, AVIF at its default quality (75) was clean and 21% smaller than lossless WebP, but not dramatically so.

Lossless photos: neither format is magic

For completeness, we also ran the photos losslessly. The astronaut went from 422,309 bytes as optimized PNG to 326,438 bytes as lossless WebP (23% smaller), at a painful 5.7 seconds of encode time with method 6. AVIF at quality 100 with 4:4:4 chroma came out at 291,842 bytes, but with an SSIM of 0.9972: Pillow's quality-100 AVIF is near-lossless, not bit-exact. If you need archival fidelity, store the original PNG or a lossless WebP and generate lossy derivatives from it. Do not assume "quality 100" means lossless in any encoder.

Same image, different encoder: the sharp cross-check

Most JavaScript build pipelines don't use Pillow. They use sharp, which wraps libvips. To see how much the encoder matters, we pushed the same astronaut image through sharp 0.35.6 (libvips 8.18.8) at its default settings, on Node 22.23.5:

const sharp = require("sharp");
await sharp("astronaut.png").webp().toFile("a.webp");                 // 31,724 B
await sharp("astronaut.png").avif().toFile("a.avif");                 // 16,423 B, SSIM 0.9419
await sharp("astronaut.png").jpeg({ quality: 80, mozjpeg: true })
  .toFile("a.jpg");                                                   // 38,183 B, SSIM 0.9462
await sharp("astronaut.png").webp({ lossless: true }).toFile("l.webp"); // 340,954 B

Three lessons came out of this cross-check.

A better JPEG encoder narrows the gap. sharp's mozjpeg mode made a quality-80 JPEG of 38,183 bytes with SSIM 0.9462. That is 17% smaller than Pillow's 45,960-byte JPEG, at essentially the same score. Against mozjpeg, default WebP (31,724 bytes) is only 17% smaller, not 31%. Many "WebP saves a third" claims are really "WebP beats an unoptimized JPEG". If your fallback JPEGs are not run through mozjpeg, fix that first. It's free bytes for the 3% of visitors who never see your AVIF.

Defaults are not comparable across libraries. sharp's default AVIF was 16,423 bytes, far smaller than Pillow's default (35,093 bytes at quality 75). It also scored lower (SSIM 0.9419, just under the JPEG target). It took about 1.7 seconds warm on our machine, against Pillow's 167 ms at speed 6. The two libraries chose different points on the size, quality and time curve. If someone tells you "AVIF is slow" or "AVIF is tiny", ask which library and which settings they used.

Lossless WebP varies by effort. sharp's default lossless WebP of the dashboard screenshot was 38,320 bytes in 424 ms. Pillow's method-6 lossless was 27,704 bytes but took 2.2 seconds. For screenshots you encode once, spend the effort. For on-the-fly conversion, the faster default is still far smaller than the PNG.

Serving both: the <picture> pattern and its trade-offs

MDN's guidance is to provide a WebP, JPEG or PNG fallback through <picture> when you serve AVIF. With both formats above 96% support, the question is whether the fallback is worth the extra files. Here is the markup we would use for a hero image:

<picture>
  <source type="image/avif" srcset="/img/hero-800.avif 800w, /img/hero-1600.avif 1600w" sizes="(max-width: 800px) 100vw, 800px">
  <source type="image/webp" srcset="/img/hero-800.webp 800w, /img/hero-1600.webp 1600w" sizes="(max-width: 800px) 100vw, 800px">
  <img src="/img/hero-800.jpg" width="800" height="420" alt="Dashboard showing build times by branch" fetchpriority="high">
</picture>

The browser picks the first <source> whose type it supports, so order matters: AVIF first, then WebP, then the plain <img>. Keep the width, height and alt on the <img>. That element still carries layout and accessibility for the whole <picture>.

When the fallback is not worth it

  • Thumbnails and avatars. At a few kilobytes each, triple storage plus build time outweighs the bytes saved. Ship WebP only.
  • Open Graph and social images. Social crawlers fetch a single URL from og:image, with no <picture> negotiation. Use PNG or JPEG there for the widest crawler compatibility. Our OG image generator outputs PNG for that reason.
  • Images in CSS. image-set() supports type negotiation, but it is easy to get wrong. If you only have one CSS background, WebP is the safe single choice.
  • Email. Email clients are not browsers. Stick to PNG and JPEG.

Content negotiation instead of markup

Image CDNs can choose the format from the request's Accept header, so you write one <img src> and the edge returns AVIF, WebP or JPEG. That keeps markup simple, but the response then varies by request header. Make sure the CDN sends Vary: Accept or uses its own cache key, or a shared cache can serve AVIF to a client that asked for JPEG. Our Cache-Control headers guide covers how shared caches key responses.

Decision table

ContentFirst choiceWhyWatch out for
Photos, hero images, product shotsAVIF42–53% smaller than JPEG at equal SSIM in our testEncode time; no progressive rendering
Screenshots, UI captures, diagrams with textLossless WebP74% smaller than optimized PNG, bit-exact16,383 px dimension cap on tall captures
On-demand / user-upload transcodingWebP5.5–8× faster encode than AVIF at default speedLeaves 27–30% of bytes on the table vs AVIF
Logos, icons, line artSVGResolution-independent, often smallestOptimize it first, e.g. with our SVG optimizer
Open Graph / social share imagesPNG or JPEGSingle URL, crawler compatibilityOur generator outputs 1200×630 PNG
HDR or wide-gamut imagesAVIFMDN lists HDR support for AVIF, not WebPTest colour handling end to end
FaviconsICO + PNG (+ SVG)Format support differs across search and browsersSee our favicon generator

What the benchmarks leave out

An honest benchmark lists its blind spots. Ours has four.

Decode cost is not measured. We timed encoding only. On low-end phones, decoding a large AVIF can take longer than decoding the equivalent WebP or JPEG, and that cost lands on your visitor's CPU. If your audience is mostly on budget Android devices, test Largest Contentful Paint on real hardware rather than trusting file size alone.

Four images are not a corpus. The photo results were consistent, and they match the vendor numbers, which is reassuring. A product catalogue of white-background shots, or a gallery of film grain, can behave differently. Run the script above on 50 of your own images before you set a site-wide quality.

SSIM is one metric. As the screenshot showed, it can rank a visibly damaged image above a clean one. Use it to narrow the field, then look at crops.

Encoders change. These numbers are for libaom through Pillow 13.0.0 and libwebp at Pillow's defaults. Other encoders (SVT-AV1, rav1e, or cwebp with different flags) produce different trade-offs. Record the encoder version next to any quality setting you standardize on.

A rollout plan for an existing site

  1. Inventory. Count images by type and weight. The largest 20 images usually dominate total bytes.
  2. Convert the heaviest photos to AVIF with a matched-quality search like the script above, keeping the JPEG as fallback. Check five crops by eye.
  3. Convert screenshots to lossless WebP. This is often the single biggest byte win on documentation and developer-tool sites full of UI captures.
  4. Leave OG images, email images and favicons alone. Generate social cards with the OG image generator and validate tags with the OG tag generator.
  5. Measure. Compare page weight and LCP before and after. If LCP gets worse on mobile despite smaller files, decode time is the likely suspect.

Looking for tools that automate this? Browse image and media tooling in our product directory and open-source listings, or start from the full set of free developer tools.

FAQ

Is AVIF better than WebP?

For photos, yes on size: in our test, AVIF was 27–30% smaller than WebP at the same SSIM, and 42–53% smaller than JPEG. It is slower to encode (5.5–8× WebP at Pillow's default speed). For screenshots and UI captures, lossless WebP was the better choice.

Do all browsers support AVIF in 2026?

caniuse puts AVIF at 96.71% global usage, with support in Chrome 85+, Firefox 93+, Edge 121+ and Safari 16.4+ (16.1–16.3 partial). WebP is slightly higher at 97.32%. A JPEG or PNG fallback in <picture> covers the remainder.

Does Google index AVIF and WebP images?

Yes. Google's image SEO documentation lists BMP, GIF, JPEG, PNG, WebP, SVG and AVIF as supported formats for images referenced in an img element's src.

What quality setting should I use for AVIF?

There is no universal value. To match a quality-80 JPEG's SSIM, our photos needed AVIF quality 56–62 in Pillow, and a text-heavy screenshot showed artefacts at the SSIM-matched setting. Search to a target metric per image, then set a floor (we would not go below Pillow's default of 75 for images containing text).

Should I use WebP or PNG for screenshots?

Lossless WebP. Our 1280×800 dashboard screenshot was 27,704 bytes as lossless WebP against 106,717 bytes as optimized PNG: bit-identical pixels, 74% smaller. Only use PNG where WebP is not accepted, such as some email clients.

Should I re-encode existing JPEGs to AVIF or WebP?

Convert from the original source file if you still have it, not from the published JPEG. Re-encoding a JPEG stacks a second set of compression artefacts on top of the first, and the new encoder spends bytes faithfully preserving the old JPEG's blocking. If only the JPEG exists, convert it at a slightly higher quality than you would use for a fresh source, and check crops of detailed areas before replacing anything in production.


Benchmarks run on 4 December 2026 with Pillow 13.0.0, Python 3.13.18, scikit-image 0.26.0 and sharp 0.35.6 (libvips 8.18.8). Browser support figures from caniuse, October 2026 usage data.

Stay Updated

Get the next deep dive in your inbox

Subscribe for product analysis, engineering explainers, and practical guides published on TechLogHub.

See what launched this week

One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.