Maximum AVIF Resolution Supported by libavif
This article explains the maximum image resolution that the
libavif library can encode. It covers the technical limits
defined by the AV1 video standard, how AVIF grid containers can bypass
these limitations, and the practical hardware constraints that affect
real-world encoding.
The Absolute Limit for a Single Image
The maximum resolution that libavif can encode into a
single, non-tiled image is 65,536 x 65,536 pixels
(approximately 4.29 gigapixels).
This limit is inherited directly from the AV1 video codec specification, which serves as the foundation for the AVIF container format. The AV1 bitstream syntax allocates 16 bits for representing both image width and image height, establishing an absolute hardware-coded coordinate boundary of \(2^{16}\) pixels in either direction.
Exceeding the Limit with Grid Images (Tiling)
If you need to encode an image larger than 65,536 x 65,536 pixels,
libavif supports a feature called grid
items (or image tiling).
The AVIF specification allows a single large image to be split into a grid of smaller, independently encoded AV1 image items. The decoder then reconstructs these pieces into a single canvas. By utilizing grids, the theoretical resolution limit becomes virtually unlimited, as you can tile multiple 65,536-pixel segments together.
Practical Encoding Constraints
While the format itself allows for massive resolutions, you may encounter practical limitations during the encoding process:
- Encoder Backends:
libavifacts as a multiplexer that relies on external AV1 codecs likelibaom,rav1e, orSVT-AV1for the actual compression. Different encoders have their own internal maximum resolution limits and memory requirements that may restrict you to resolutions lower than 65,536 pixels. - System Memory (RAM): Encoding extremely high-resolution images is highly resource-intensive. Attempting to encode a 4-gigapixel image without tiling will often fail due to Out-Of-Memory (OOM) errors, as the encoder requires several gigabytes of RAM to process the image frame.
- Decoder Compatibility: Many web browsers and image
viewer decoders struggle to render AVIF images that approach the maximum
theoretical limit due to device RAM constraints, even if
libavifsuccessfully encoded the file.