ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: olegos on February 16, 2022, 02:09:36 AM

Title: Adding QuickTime:Rotation in HEIC file
Post by: olegos on February 16, 2022, 02:09:36 AM
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
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: blue-j on February 21, 2022, 04:14:36 PM
Is this a field for videos only, or images, too?

- J
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: olegos on February 23, 2022, 01:42:30 AM
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).
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: wywh on February 23, 2022, 06:44:20 AM
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
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: olegos on February 23, 2022, 06:26:41 PM
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)
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: olegos on April 29, 2023, 02:15:50 PM
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.
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: olegos on April 29, 2023, 02:25:39 PM
Attached is an example of an image that I cannot rotate by just modifying the metadata

Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: wywh on April 29, 2023, 03:15:16 PM
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
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: StarGeek on April 29, 2023, 03:58:30 PM
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?
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: olegos on April 29, 2023, 04:36:40 PM
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).
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: Phil Harvey on May 01, 2023, 07:50:42 AM
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
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: StarGeek on May 01, 2023, 11:39:14 AM
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?
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: Phil Harvey on May 01, 2023, 04:22:53 PM
ExifTool can't currently do that.

- Phil
Title: Re: Adding QuickTime:Rotation in HEIC file
Post by: Phil Harvey on May 03, 2023, 01:55:14 PM
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