Hello,
I'm able to use exiftool to modify QuickTime:Rotation in HEIC file only if it already exists. If it doesn't exist, it doesn't get added and the file is unchanged. Would be very nice to be able to set this tag regardless of whether it already exists, to losslessly rotate HEIC files.
(attempts to copy this tag from another file where it exists with -tagsFromFile, or copy all QuickTime tags as a block, all failed as well)
Thank you!!
* using ExifTool 12.40
Is this a field for videos only, or images, too?
- J
Quote from: blue-j on February 21, 2022, 04:14:36 PM
Is this a field for videos only, or images, too?
In my case, images; don't know about videos. Latest Samsung phones can save photos as HEIC files, with QuickTime tag group. Photos in portrait orientation have Rotation tag set in QuickTime and Orientation in EXIF, but in landscape orientation, Rotation in QuickTime is not present. As a result I can rotate some images by rewriting both QuickTime:Rotation and EXIF:Orientation, but not others (apparently rewriting just the latter is not sufficient for some viewers).
Quote from: olegos on February 23, 2022, 01:42:30 AM
Latest Samsung phones can save photos as HEIC files, with QuickTime tag group. Photos in portrait orientation have Rotation tag set in QuickTime and Orientation in EXIF, but in landscape orientation, Rotation in QuickTime is not present.
iPhone 13 Pro has the following for .heic:
exiftool -a -G1 -s -Rotation -Orientation *.heic
======== horizontal.heic
[QuickTime] Rotation : 0
[IFD0] Orientation : Horizontal (normal)
[XMP-tiff] Orientation : Horizontal (normal)
======== portrait.heic
[QuickTime] Rotation : 270
[IFD0] Orientation : Rotate 90 CW
[XMP-tiff] Orientation : Rotate 90 CW- Matti
Quote from: wywh on February 23, 2022, 06:44:20 AM
iPhone 13 Pro has the following for .heic:
exiftool -a -G1 -s -Rotation -Orientation *.heic
Here's the same for HEIC from Samsung Galaxy S21:
exiftool -a -G1 -s -Rotation -Orientation 20211001_174412.heic
[QuickTime] Rotation : 270
[QuickTime] Rotation : 270
[IFD0] Orientation : Rotate 90 CW
exiftool -a -G1 -s -Rotation -Orientation 20211001_072126.heic
[IFD0] Orientation : Horizontal (normal)
Ping. This still doesn't work with the latest version, 12.61. So I cannot losslessly rotate HEIC images from Samsung phones by modifying Rotation/Orientation, the way I can with jpegs. Doesn't work only if the originals are in landscape orientation, and works properly if the images start in portrait orientation.
Attached is an example of an image that I cannot rotate by just modifying the metadata
Quote from: olegos on April 29, 2023, 02:25:39 PMrotate by just modifying the metadata
Try:
exiftool -n -IFD0:Orientation=6 test.heic
exiftool -a -G1 -s -n test.heic
[IFD0] Orientation : 6
Unlike exiftool (?), macOS 13 Ventura Preview can also add QuickTime:Rotation. IFD0:Orientation remains the same but at least Mac apps correctly display the rotated .heic:
[QuickTime] Rotation : 0
[IFD0] Orientation : 1
After that, this exiftool command succeeds to turn the .heic up-side-down:
exiftool -n -QuickTime:Rotation=180 test.heic
[QuickTime] Rotation : 180
[IFD0] Orientation : Horizontal (normal)
Which tag (or both) is the standard?
- Matti
Can you share an image that is already rotated properly without editing to compare?
Edit: The problem seems to be the lack of the QuickTime:MatrixStructure tag. With my quick tests and limited samples, the files that had the QuickTime:MatrixStructure could be rotated and the ones without could not. But when it comes down to it, no viewer I tried was honoring the EXIF:Orientation.
Phil, since HEIC are closely related to videos, are they the same in that there isn't a standard for embedding EXIF data?
Quote from: StarGeek on April 29, 2023, 03:58:30 PMCan you share an image that is already rotated properly without editing to compare?
See the two attached files. The _original one is how it came off the phone. The rotated one is the result of
exiftool -Orientation=3 -QuickTime:Rotation=0 20211227_164541.heic
Edit: apparently I messed up Orientation there, but it doesn't seem to matter anyway, only QuickTime:Rotation seems to matter. The final file is shown rotated properly in several viewers I've tried (in Windows).
Quote from: StarGeek on April 29, 2023, 03:58:30 PMPhil, since HEIC are closely related to videos, are they the same in that there isn't a standard for embedding EXIF data?
HEIC does support EXIF, and many of the samples I have store both EXIF:Orientation and QuickTime:Rotation, but some have EXIF:Orientation only.
- Phil
So the root question is still the same. Is it possible to add the QuickTime:MatrixStructure to a file that doesn't have it to begin with?
ExifTool can't currently do that.
- Phil
I just ran some tests, and MacOS Mojave software respects the EXIF:Orientation tag in HEIC images, but apparently newer versions of the software rotate images differently than Mojave.
- Phil
Rotating HEIC files (and AVIF files which have same container) is still impossible with exiftool (at least couple of months ago when I last tested. Here are some of my related observations:
- majority of apps seem to decide HEIC/AVIF orientation from -quicktime:rotation tag.
- BUT there ARE some apps which read even the normal exif orientation tag from these files. I am not sure if there was even apps that read both and have some logic them which one to use?
- I was unable to modify rotation of AVIF file with exiftool. I might have been able to do that for some HEIC images but not for all orientations (if I don't remember incorrectly it was unable to set rotation to 180, but 90 and 270 were ok)
- the only app that I've been able to use reliably to modify rotation of AVIF/HEIC file is MS Photos. BUT it does NOT modify orientation so you can end up in situation where one apps shows landscape and another one portrait.
- application of orientation/rotation for AVIF files is still probably a minority thing but I use it. I batch convert large amount of HEIC/JPG to AVIF (or JXL). Sometimes I notice afterwards that there is wrong orientation and want to fix it without re-encoding. Application of orientation/rotation for HEIC files has large target audience as Apple forces HEIC pics and androids also have option to save as HEIC. I am not encouraging anybody to use HEIC format as app developers are avoiding it (due to potential licensing issues). But state of things is that there are a lot of HEICs out there and they must be rotated reliably.
Seems a bit pain that there are 2 orientation related tags. Not sure what is the best way to deal with this. Probably to convince major app developers (Apple, Microsoft, Adobe, etc..) to use only one of them and smaller developers will follow suit. But while waiting for that the safest file has orientation both in orientation tag and quicktime:rotation tag. And this is what I would to with exiftool if it were able to modify rotation reliably.
ExifTool can edit QuickTime:Rotation if it exists, but can't yet create it if it doesn't.
The reason is because of the overly-complex format of HEIC, and the associated difficulty adding this feature. But I'll add this to my to-do list, and maybe I'll find some time to look into it.
- Phil
Quote from: Phil Harvey on July 01, 2025, 07:33:39 PMExifTool can edit QuickTime:Rotation if it exists, but can't yet create it if it doesn't.
The reason is because of the overly-complex format of HEIC, and the associated difficulty adding this feature. But I'll add this to my to-do list, and maybe I'll find some time to look into it.
- Phil
Maybe you could ask insights/help from MS Photos team @ Microsoft or related team @ Apple? As they have already done it. Or is their policy to ignore open source developers? I really don't know how these things work. Anyway reinventing the whole wheel feels a bit pointless. IMO its not like NTFS where MS made (AFAIK) open source community to reverse-engineer the whole thing. Even MS/Apple might benefit from these formats becoming more common as they host a lot of content which consumes a lot of bandwidth.
Anyway is it not kind of 2 flies with one hit problem as both HEIC and AVIF share the same HEIF container format? So that if you solve it for HEIC it is at same time solved for AVIF?
Asking wouldn't help, even if they answered (which they wouldn't). I know what to do already. The problem is the work involved in doing it.
- Phil