AVIF
The content in this entry is incomplete & is in the process of being completed.
AVIF, which stands for AV1 Image File Format, is a newer image codec that is based on the AV1 video codec. AVIF supersedes HEIC, & uses the same HEIF container as HEIC. AVIF is designed to have a better featureset & better general lossy compression than older image codecs, including WebP, HEIC, & JPEG. AVIF is often compared to JPEG-XL, though in practice, the two have very different strengths.
There are two AVIF profiles available for encoding: Baseline & Advanced, which are based on AV1's Main & High profiles respectively. The AVIF Baseline profile supports up to 8,192*4,352 resolution specified by the requirement of using AV1 Level 5.1 or lower. Using tiling, it is possible to increase the maximum resolution of the AVIF Baseline profile to 65536*65536, although this hurts coding efficiency as visual anomalies may be encountered along the edges of the tile boundaries. AVIF is also limited to 10 bit color precision in its Baseline profile.
In the AVIF Advanced profile, the maximum image dimensions extend to 16,384*8,704. Tiling may be used in the Advanced profile to create larger images, but the same limitations regarding visual artifacts apply. The AVIF Advanced profile extends the allowed AV1 Level to 6.0 or lower, & the highest bit depth offered by this profile is 12 BPC. It is worth noting that while it is currently a near certainty that AVIF implementations will support both the Baseline & Advanced profiles, this may not always be the case. This is a problem that affects HEIC currently, & is a known potential weakness of video-based image codecs.
Performance Checklistâ
Lossless? Poorly
Lossy? Yes
Supported Bit Depths: 8 BPC, 10 BPC, 12 BPC
HDR/Wide Gamut? Yes
Animation? Yes
Transparency? Yes
Progressive Decode? No
Royalty Free? Yes
Compatible Browsers (full support)
Format Breakdownâ
Advantagesâ
AVIF is known for its extremely strong lossy compression performance for non-photographic images as well as photographic images. AVIF is consistently better than JPEG visually.
Using libaom's --tune iq
or SVT-AV1-PSY's Tune 4, AVIF is generally the most efficient image codec on the Web for quality per bit. AVIF's quality per bit is generally better than JPEG XL, though JPEG XL is considerably more feature-rich.
AVIF compatibility has grown rapidly since its adoption in Google Chrome in 2020. For a relatively new image format, its level of penetration has been stellar, especially in the browser market; AVIF is considered Baseline as of 2024.
AVIF's wider featureset enables new experiences through images, including HDR. AVIF also presents astonishing animation prowess, as it is capable of using AV1's video coding techniques which make it easily the best animated image format for most use cases.
Limitationsâ
AVIF encoding implementations are difficult to use, and images require much longer encoding times for what can be considered competitive quality. Making encoding more difficult, AVIF's use of intra-frame coding techniques that share data between blocks reduces parallelization capability & worsens generation loss. Theoretically, this improves coding efficiency, though. Via the AVIF Encoding section of the aomenc page:
AVIF Encoding with aomenc through avifenc
Using aomenc through avifenc is widely considered to be the best way to encode AVIF images, as SVT-AV1 only supports 4:2:0 chroma subsampling, rav1e isn't fast enough for still images, & the libaom team have put more effort into intra coding than the teams responsible for producing the other prominent open source AV1 encoders.
A sample command for encoding AVIF looks like this:
avifenc -c aom -s 4 -j 8 -d 10 -y 444 --min 1 --max 63 -a end-usage=q -a cq-level=16 -a tune=ssim [input] output.avif
Where:
-c aom
is the encoder-s 4
is the speed. Speeds 4 & below offer the best compression quality at the expense of longer encode times.-j 8
is the number of threads the encoder is allowed to use. Increasing this past 12 will sometimes hurt encode times, as AVIF encoding via aomenc doesn't paralellize perfectly. Test using a speed benchmark to verify which value works best for you.-d 10
is the bit depth. Specifying a value below 10 isn't recommended, as it will hurt coding efficiency even with an 8 bit source image.-y 444
is the chroma subsampling mode. 4:4:4 chroma subsampling tends to provide better compression than 4:2:0 with AVIF, though on some images 4:2:0 chroma subsampling might be the better choice.cq-level=16
is how you specify quality. Lower values correspond to higher quality & filesize, while higher values mean a smaller, lower-quality output is desired. This is preceded by-a
because it is an aomenc option, not an avifenc one.tune=ssim
is how the encoder handles RDO (rate-distortion optimization). This may be redundant with the default aomenc parameters, but specifying doesn't hurt to avoid an unintended change if a default is modified sometime in the future.
AVIF does not have progressive decode. This is a common weakness of video-based image codecs. While there is a hacky way to do progressive AVIF by encoding a low fidelity frame & then a high fidelity frame in an animated AVIF at a high framerate so the low fidelity frame is loaded & plays first, this is far from ideal for the average user & adds to an already burdensome encoding process. Additionally, this has issues with Firefox.
Finally, AVIF's lossless mode is underwhelming, often producing larger files than PNG. When compressing losslessly, it can generally be advised that you avoid AVIF.
Encodersâ
AV1 Encodersâ
In practice, any usable AV1 encoder should be able to produce AVIF images. This makes our list of feature-complete, open-source AVIF encoders end up looking quite familiar:
In the proprietary space, Aurora1 was used at Cloudinary (a major multimedia CDN) for AVIF compression for a while, but has since been replaced by libaom.
tinyavifâ
Rachel Barker's tinyavif is a barebones AVIF encoder that is designed to be easy to understand. It is not feature-complete, but it is a good choice for those who want to learn more about how AVIF works (and by extension, how AV1 works). It is written in Rust, and is described as "the world's most minimal AV1 encoder."
Conclusionâ
AVIF is a strong image format that is worth considering for use on the web. It is a great choice for images that are not high fidelity, as it will compress better than JPEG in most cases. AVIF is also a great choice for animated images, as it is the best format for this use case. However, AVIF is not a great choice for lossless images, as it tends to produce larger files than PNG. Overall, AVIF is a great format to use for images that are not high fidelity, as it will compress better than JPEG in most cases.