Adding QuickTime:Rotation in HEIC file

Started by olegos, February 16, 2022, 02:09:36 AM

Previous topic - Next topic

olegos

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

blue-j

Is this a field for videos only, or images, too?

- J

olegos

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).

wywh

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

olegos

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)

olegos

#5
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.

olegos

Attached is an example of an image that I cannot rotate by just modifying the metadata


wywh

#7
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

StarGeek

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?
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

olegos

#9
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).

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

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?
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

ExifTool can't currently do that.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).