AVIF Reader Transform Order of Operations
This article provides an overview of the mandatory order of operations that an AVIF compliant reader must follow when applying image transformations. Because AVIF relies on the Multi-Image Application Format (MIAF) and ISOBMFF specifications, decoders must apply operations like cropping, rotation, and reflection in a strict sequence to ensure images render consistently across different software and platforms.
The Standard Execution Pipeline
When processing an AVIF file, an image reader first parses the container boxes, extracts the primary item, and decodes the underlying AV1 bitstream into an uncompressed pixel grid. Once the pixel data is reconstructed, any transformative item properties associated with the image item must be evaluated.
According to the MIAF (ISO/IEC 23000-22) specification adopted by AVIF, transformative item properties must be applied in the following strict sequential order:
- Clean Aperture (
clap) - Image Rotation (
irot) - Image Mirroring (
imir)
1. Clean Aperture
(clap)
The clean aperture property defines a cropping rectangle. It specifies the exact width, height, and fractional offsets relative to the decoded image dimensions.
- The reader must crop the decoded image data to this defined rectangle first.
- All subsequent spatial transformations operate strictly on this cropped boundary rather than the original decoded pixel canvas.
2. Image Rotation
(irot)
The image rotation property specifies an anti-clockwise rotation angle restricted to increments of 90 degrees (specifically 0, 90, 180, or 270 degrees anti-clockwise, commonly implemented as 90, 180, or 270 degrees clockwise).
- The reader applies this rotation directly to the output of the clean aperture step.
- If no
clapproperty is present, the rotation applies directly to the fully decoded image canvas.
3. Image Mirroring
(imir)
The image mirror property specifies a reflection axis, indicating whether the image should be flipped horizontally or vertically.
- The reader applies the mirror transformation to the already cropped and rotated image.
- This is the final geometric transformation in the pipeline.
Importance of the Sequence
Applying spatial transformations in any other sequence produces
incorrect visual output. For example, cropping an image after rotating
it would target coordinates on the rotated canvas, misaligning the
intended crop region defined by the original author. By standardizing
the pipeline as clap \(\rightarrow\) irot \(\rightarrow\) imir, compliant
readers guarantee pixel-identical geometry across all implementations
before final color management profiles (such as ICC or CICP color
characteristics) and alpha blending are applied for display.