-
Notifications
You must be signed in to change notification settings - Fork 309
Description
Is your feature request related to a problem?
HEIF files from cameras like Sony A7 IV use the irot (image rotation) transformative property to indicate orientation. However, exiv2 does not parse this box, so Exif.Image.Orientation is not populated for these files.
This causes problems in applications like digiKam that rely on exiv2 for metadata: portrait photos display with incorrect orientation because no orientation information is available.
# Sony A7 IV HEIF file - exiv2 shows no orientation
$ exiv2 -g Orientation DSC02105.HIF
Exif.SonyMisc3c.CameraOrientation Byte 1 Rotate 270° CW
# But exiftool shows the irot data exists
$ exiftool -G1 -Rotation -Orientation DSC02105.HIF
[QuickTime] Rotation : 90
The irot box is already recognized by the boxHandler (visible in -pS output) but its value is not extracted.
Describe the solution you would like
Parse the irot box in bmffimage.cpp and synthesize Exif.Image.Orientation from it when EXIF orientation is not already present in the file. The mapping from irot angle (anti-clockwise, 0-3) to EXIF orientation would be:
| irot | Rotation | EXIF Orientation |
|---|---|---|
| 0 | 0° | 1 (top, left) |
| 1 | 90° CCW | 8 (left, bottom) |
| 2 | 180° | 3 (bottom, right) |
| 3 | 270° CCW | 6 (right, top) |
This follows the pattern already used for camera-specific rotation tags in easyaccess.cpp.
Describe alternatives you have considered
- ExifTool script: Currently using a shell script that copies
CameraOrientationtoOrientationusing exiftool. Works but requires modifying files and running on import. - Fix in digiKam: Would only help digiKam users, not other exiv2-based apps.
- Expose irot as separate property: More architecturally pure, but would require changes to all consuming applications.
Desktop
- OS and version: Linux (Ubuntu 24.04 / Pop!_OS)
- Exiv2 version and source: main branch (commit 872237d)
- Any software using exiv2 and source: digiKam 8.8.0 (Flatpak)
Additional context
This probably affects all HEIF-producing cameras that use irot without setting EXIF orientation, including:
- Sony A7 IV (.HIF files)
- Canon (CR3/HEIF)
- Likely others
The existing test files in tests/bugfixes/github/test_pr1475_HIF.py show irot boxes being detected but not parsed:
Exiv2::BmffImage::boxHandler: irot 577->9
I have a draft implementation that works well on my Sony files, if you'd like me to submit a PR. I created it using Claude Code.