How AVIF Handles Non-Destructive Edits and Rotation
The AV1 Image File Format (AVIF) enables non-destructive edits—such as rotation, mirroring, and cropping—by storing transformation instructions as metadata properties within its container rather than modifying the underlying compressed AV1 pixel data. This article explains the underlying container architecture, the specific property boxes used for transformations, and the performance and quality advantages of this approach.
The Container Architecture: ISOBMFF
AVIF uses the ISO Base Media File Format (ISOBMFF), standardizing it under the High Efficiency Image File Format (HEIF) specification (ISO/IEC 23000-12). In this framework, the raw image data (the AV1 bitstream) is separated from how that data is presented.
When an AVIF file is created or modified, edits are attached as
descriptive item properties in the file's iprp (Item
Properties) box. Because the encoded AV1 pixel stream remains untouched,
users can repeatedly apply, modify, or remove edits without causing
generation loss or recompression artifacts.
Handling Image Rotation:
The irot Box
Instead of decompressing the AV1 bitstream, rotating the pixel grid,
and re-encoding it, AVIF handles rotation through an irot
(Image Rotation) property box.
- How It Works: The
irotproperty contains a 2-bit integer that signals the display engine to rotate the image before rendering. - Values:
0: 0 degrees1: 90 degrees counter-clockwise2: 180 degrees3: 270 degrees counter-clockwise
- Decoupling from EXIF: While AVIF can encapsulate
legacy EXIF metadata (which also contains an orientation tag), decoders
that support the ISOBMFF specification prioritize the
irotbox for rendering to ensure consistent behavior across different web browsers and viewers.
Handling Mirroring: The
imir Box
Flipping an image is similarly handled through an imir
(Image Mirror) property box.
- How It Works: The property designates an axis of reflection.
- Values: It specifies whether the mirror operation should occur along the vertical axis (left-to-right flip) or horizontal axis (top-to-bottom flip).
- Combination: When paired with the
irotproperty, decoders apply the properties sequentially based on the order defined in the file, allowing any combination of orientation and reflection.
Handling Cropping: The
clap Box
AVIF manages non-destructive cropping using the clap
(Clean Aperture) property box.
- How It Works: Instead of discarding pixels outside
the desired crop area,
clapspecifies four fractional values: clean aperture width, clean aperture height, horizontal offset, and vertical offset. - Rendering: When the decoder parses the file, it renders only the rectangular area defined by the clean aperture parameters, ignoring the outlying compressed pixels. The full original frame remains intact within the file.
Advantages of Non-Destructive Container Edits
- Zero Generational Loss: Traditional lossy image formats lose quality each time an edit requires re-encoding. AVIF preserves the original compression quality indefinitely.
- Instant Execution: Modifying a byte in a header property takes milliseconds and minimal computing power compared to decompressing and re-encoding complex AV1 video frames.
- Reversibility: Because the original pixel payload remains unchanged, any software with write access to the ISOBMFF metadata can revert transformations to restore the original capture.