← Blog

Why AVIF takes several times longer to encode than JPEG

Same 12 MP photo, same WASM_QUALITY = 85, very different time and size Encode time, 12 MP photo JPEG (canvas, q 0.85) ~120 ms PNG (canvas, lossless) ~180 ms WebP (canvas, q 0.85) ~250 ms AVIF (WASM, q 85) ~600–1500 ms Variance is high: AVIF tries dozens of block-partition and prediction-mode combinations per coding unit before picking the best. File size, same photo JPEG q 85 ~2.4 MB WebP q 85 ~1.7 MB (~30% smaller) AVIF q 85 ~1.2 MB (~50% smaller) AVIF averages around 50% the size of JPEG, in exchange for 5–10× the encode time. Smooth photo content can do better; busy textures do worse. Decode is slower than JPEG but fast enough.

The slowest part of converting an image to AVIF is the encode itself. The decoder side is fine — once a file is written, every modern browser displays it in single-digit milliseconds per megapixel, slower than JPEG but fast enough that no one notices. The asymmetry is on the encoder side, and it comes from the fact that AVIF is a still-image wrapper around a video codec.

What AVIF actually is

AVIF stands for AV1 Image File Format. The container is the same ISOBMFF box layout used by HEIC and MP4. The pixel data inside is a single intra-frame from the AV1 video codec — the same codec that streams 4K video on YouTube and Netflix. AV1 was designed to be used at huge scale where every saved bit pays for itself thousands of times over, and its encoder is correspondingly thorough.

JPEG, by contrast, is a 1992 still-image codec built around an 8×8 Discrete Cosine Transform with a fixed structure. Encoding a JPEG is essentially: split into 8×8 blocks, transform each one, divide by a quantization table, run-length and Huffman code the result. There are no decisions to make beyond the quality factor.

Where AVIF spends its time

AV1's encoder asks several questions for every region of the image, recursively:

JPEG just does the DCT and stops. AVIF runs an elaborate search per megapixel.

Our quality 85 isn't JPEG's quality 85

Both formats accept a 0–100 quality number, and we use 85 for both as the default. They mean very different things internally. JPEG's 85 maps to a specific quantization-table scaling factor — well-defined since 1992. AVIF's 85 maps onto the AV1 encoder's perceptual quantizer, which adjusts per block based on a distortion metric. The visual result at the same nominal number is comparable, but the encoder reaches it through a much more elaborate search.

How much smaller, really

Quoted "AVIF is 50% smaller than JPEG" numbers are roughly accurate as an average across typical photographic content, but real-world results vary a lot. Smooth content — skies, skin, soft-focus backgrounds — can compress dramatically better in AVIF (up to 2–3× over JPEG at the same perceived quality). Busy content — foliage, dense textures, fine text — closes the gap; AVIF may end up only 20–30% smaller. WebP usually sits in between, around 25–30% smaller than JPEG.

If size matters and the wait is acceptable, AVIF is the right choice for photographic outputs. If you need consistently fast encoding across a batch and the size win at AVIF's typical advantage isn't worth the encoder time, WebP is the practical middle ground.

When AVIF is, and isn't, worth the wait

For a single 12 MP photo destined for the web, the wait pays off: roughly a second of extra encoding gets you a file about half the size of JPEG, which downloads twice as fast on every visitor's connection forever. For a batch of 50 such photos, the wait is half a minute. Acceptable.

For images smaller than about a megapixel — favicons, UI sprites, small thumbnails — the absolute byte saving over JPEG or WebP is small (a few KB) and AVIF's encoder overhead doesn't amortise. WebP at quality 85 is a much better trade in that range: still a meaningful size reduction over JPEG, but only 2–3× JPEG's encode time instead of 5–10×.

What the converter does

AVIF is on our WASM_ENCODE list, which means it goes through the bundled WASM image library rather than the browser's native canvas encoder. The library calls into a bundled AV1 intra-frame encoder; the same encoder is used for every AVIF output regardless of source format. There is no browser fast path for AVIF output the way there is for JPEG and WebP. If you batch-convert a hundred files to AVIF, expect minutes; convert the same hundred to WebP and expect seconds.