How AVIF imir Box Indicates Image Flipping

The AVIF image format uses transformative item properties inherited from the High Efficiency Image File Format (HEIF) and the ISO Base Media File Format (ISOBMFF) to alter image presentation without re-encoding the underlying bitstream. Among these properties, the Image Mirroring box (imir) is responsible for indicating horizontal and vertical image flipping. By storing a single flag value inside the file's metadata container, the imir box instructs decoders to invert the decoded pixel grid along a specified axis before rendering.

The Structure of the imir Box

The imir box is an item property stored within the file's metadata (meta) container, specifically inside the Item Properties Box (iprp). It is classified as an essential or non-essential transformative property associated with specific image items via the Item Property Association (ipma) box.

The payload of the imir box consists of a single byte containing an 8-bit layout defined as follows:

How the mode Field Dictates Orientation

The mode field defines the reflection axis for the mirror operation:

Application Order and Non-Destructive Transformations

AVIF decoders apply transformations non-destructively. When an image contains both rotation (irot) and mirroring (imir) boxes, the transformation order depends strictly on their sequence in the associated ipma box:

  1. The raw AV1 bitstream is decoded into pixel memory.
  2. The decoder inspects the sequence of transformative properties mapped to that item ID.
  3. The transformations are executed in the exact order listed. Applying an irot box before an imir box yields a different visual result than applying the imir box first.

By interpreting the imir box's single-bit mode, compliant decoders can render mirrored AVIF assets efficiently without modifying the encoded AV1 video frames.