AVIF Orientation Flags vs EXIF Orientation Tags
While traditional image formats like JPEG typically rely on embedded EXIF metadata tags to dictate image rotation and flipping, the AV1 Image File Format (AVIF) handles orientation natively at the container level. This article explains the technical differences between legacy EXIF orientation tags and AVIF's structural transformation properties, how conflicts between the two are resolved, and why the AVIF implementation leads to more reliable image rendering across the web.
The Traditional Approach: EXIF Orientation Tags
In legacy formats such as JPEG, TIFF, and WebP, orientation is
defined within an embedded EXIF (Exchangeable Image File Format)
metadata block. The camera or software writes a value from 1 to 8 into
the EXIF Orientation tag (tag ID 0x0112).
These eight integer values represent:
- 1: Normal (0° rotation)
- 2: Flipped horizontally
- 3: Rotated 180°
- 4: Flipped vertically
- 5: Flipped horizontally and rotated 270° counter-clockwise
- 6: Rotated 90° counter-clockwise
- 7: Flipped horizontally and rotated 90° counter-clockwise
- 8: Rotated 270° counter-clockwise
Because EXIF is a secondary metadata payload rather than a core structural element of the image bitstream, decoders must parse this external block to display the image properly. If an image optimizer or Content Delivery Network (CDN) strips EXIF data to reduce file size or preserve user privacy, the orientation information is lost, frequently causing images to display upside down or sideways.
The AVIF Approach: ISOBMFF Transform Properties
AVIF is derived from the HEIF specification, which is built on top of the ISO Base Media File Format (ISOBMFF). Instead of delegating display geometry solely to an embedded EXIF chunk, AVIF uses native ISOBMFF item properties to define transformations.
Orientation in AVIF is primarily controlled by two container-level properties:
irot(Image Rotation): Specifies the counter-clockwise rotation applied to the reconstructed image. The box contains a 2-bit integer that represents 0, 90, 180, or 270 degrees of rotation.imir(Image Mirroring): Specifies whether a horizontal or vertical flip should be applied before or after rotation.
These properties are part of the file's primary structural item
properties box (iprp). Because they are native container
elements, an AVIF decoder can determine the correct display layout
immediately upon reading the file header, without parsing deep metadata
structures.
Handling Conflicts: Preventing "Double Rotation"
AVIF files can still contain an embedded EXIF metadata payload to
preserve camera settings, timestamps, and geolocation. However, this
introduces the potential for conflicting orientation instructions if
both an irot/imir property and an EXIF tag
0x0112 exist.
The AVIF specification explicitly outlines how to handle this to avoid "double rotation":
- Container Precedence: Decoders must prioritize the
ISOBMFF properties (
irotandimir) for rendering. - Encoder Responsibility: Compliant AVIF encoders
that write
irotorimirproperties are instructed to either omit the EXIF orientation tag entirely or normalize it to a value of1(top-left / normal). - Fallbacks: If an AVIF file lacks
irotandimirboxes but includes an EXIF payload with an orientation tag, some decoders will fall back to reading the EXIF tag, though this behavior is not strictly required by the base specification.
Key Advantages of AVIF's Approach
By moving orientation from EXIF to the container format, AVIF offers several structural improvements:
- Safe Metadata Stripping: Privacy-conscious systems and CDNs can strip identifying EXIF data (such as GPS coordinates and device serial numbers) without corrupting the visual orientation of the image.
- Parsing Efficiency: Decoders read structural orientation alongside the primary image dimensions, allowing layout engines to reserve space accurately without a separate EXIF parsing pass.
- Consistency Across Platforms: Relying on ISOBMFF structural definitions reduces discrepancies caused by varying browser and viewer support for EXIF orientation tags.