ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: SebC on March 09, 2025, 05:27:00 PM

Title: Rotation / Orientation of iphone HEIC files
Post by: SebC on March 09, 2025, 05:27:00 PM
Hello,

I used to have an iphone XR and I was able to do pretty much all I wanted on the EXIF metadata with Exiftool : changing date, rotation etc.

Now that I have upgraded to an iphone 16, I have problems with photo orientation.

With my old iphone XR's HEIC files, I only had to run a command such as "exiftool -rotation=0/90/180/270 IMG_xxxx.HEIC" and that instantly changed picture orientation. But with my iphone 16's HEIC files, this is not working anymore ... and worse, this just make that photo unreadable on my laptop.

I also tried to alter "orientation" tag with command such as "exiftool -orientation=1..8 -n IMG_xxxx.HEIC" but this seems to be useless.

Of course I can rotate the file on my iphone directly, but when you have multiple files, this is very convenient to rotate them all with a single command line on my laptop instead of one by one and multiple actions for each on my phone.

I don't know whether this is specific to iphone 16 or if it was the same with in between models, because I switched from XR to 16.

I asked the same question in Apple forum here : https://discussions.apple.com/thread/256000863?sortBy=rank
But as Matti Haveri suggested, the question is probably better located in Exiftool forum.

I'll attach 3 files (from inside Notre-Dame de Paris for those who are wondering ;) ) :
- IMG_6161.HEIC : original picture made on iphone 16 that I want to rotate
- IMG_E6161.HEIC : the same picture with 180° rotation made directly on the iphone (and of course this works)
- IMG_5588.HEIC : almost the same place but taken with my old iphone XR, and I can rotate this one with "exiftool -rotation=0/90/180/270"

As suggested by Matti on Apple forum thread, if I extract both orientation and rotation values with Exiftool, I get :
exiftool -a -G1 -s -Rotation -Orientation *
======== IMG_5588.HEIC << iphone XR pic that I can rotate without any issue
[QuickTime]     Rotation                        : Rotate 90 CW
[IFD0]          Orientation                     : Rotate 90 CW
======== IMG_6161.HEIC << iphone 16 pic that I can't rotate with Exiftool
[QuickTime]     Rotation                        : Rotate 90 CW
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Rotate 90 CW
======== IMG_E6161.HEIC << iphone 16 pic rotated directly on iphone 16
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)

There's a bit of inconsistency in IMG_6161.HEIC as there are 2 tags "Quicktime:Rotation" with different values. Note that the "iphone rotated" photo only has one.

Updating with Exiftool the values of IMG_6161.HEIC with what I have in IMG_E6161.HEIC does not help as the resulting IMG_6161.HEIC is unreadable :
exiftool -m -P -n -Rotation=0 -Orientation=1 IMG_6161.HEIC
exiftool -a -G1 -s -Rotation -Orientation IMG_6161.HEIC

[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)

Of course I'm using latest version of Exiftool.

I can't find any combination of rotation / orientation that can rotate iphone 16 HEIC files ... so, I'm hoping an Exiftool guru can help me.

Thanks a lot !
Sebastien
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: StarGeek on March 09, 2025, 05:42:03 PM
Quote from: SebC on March 09, 2025, 05:27:00 PMNow that I have upgraded to an iphone 16, I have problems with photo orientation.

With my old iphone XR's HEIC files, I only had to run a command such as "exiftool -rotation=0/90/180/270 IMG_xxxx.HEIC" and that instantly changed picture orientation. But with my iphone 16's HEIC files, this is not working anymore ... and worse, this just make that photo unreadable on my laptop.

Orientation on HEIC files is messy, because a lot of programs don't seem to read and respect the EXIF:Orientation tag. And the Rotation tag isn't really a tag in file, it's Composite tag (https://exiftool.org/TagNames/Composite.html) that edits the QuickTime:MatrixStructure in a way that is understandable to humans. That is because HEIC files are based upon the MP4 format and look a lot like they are MP4 videos.

The fact that they become unreadable sounds like a very bad bug and Phil will have to take a look at the files to figure out what is wrong. (edit: Moved this thread to the Bug Report subforum)

QuoteI also tried to alter "orientation" tag with command such as "exiftool -orientation=1..8 -n IMG_xxxx.HEIC" but this seems to be useless.

The EXIF:Orientation is a tag that exiftool converts from numbers to a human-readable format. If you look at its entry on the EXIF Tags page (https://exiftool.org/TagNames/EXIF.html), you will see a list of values that you would use to set it. The basic ones are
-Orientation=Horizontal
-Orientation="Rotate 90 CW"
-Orientation="Rotate 180"
-Orientation="Rotate 270 CW"

If you want to use the numbers, you have to include the -n (--printConv) option (https://exiftool.org/exiftool_pod.html#n---printConv), usually by using the hashtag shortcut
-Orientation#=1
-Orientation#=6
-Orientation#=3
-Orientation#=8

QuoteI asked the same question in Apple forum here : https://discussions.apple.com/thread/256000863?sortBy=rank
But as Matti Haveri suggested, the question is probably better located in Exiftool forum.

Matti is on here as @wywh and is more experienced with the Apple environment than I am, so they might chime in here as well.
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: StarGeek on March 09, 2025, 05:54:28 PM
I did a comparison of IMG_6161.HEIC and the edited version using the -v3 (-verbose3) option (https://exiftool.org/exiftool_pod.html#v-NUM--verbose), and it looks like a lot of stuff is lost with the edit, though I'm not familiar enough with the inner workings to tell what is lost.

A comparison of the two outputs can be found here on DiffChecker (https://www.diffchecker.com/HCZOuttD/), about 3,000 lines of output.
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: Phil Harvey on March 09, 2025, 08:56:42 PM
Hi Sebastien,

I see a definite problem in the way that ExifTool is handling these two different Rotation tags when trying to change them.  I'll see what I can do, but my MacOS system is too old to display HEIC images, so testing is tricky.  Check back here and I'll likely post some samples for you to test, probably tomorrow.

- Phil
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: Phil Harvey on March 09, 2025, 09:18:17 PM
Actually, I've quickly hacked each of the two rotation tags of your IMG_6161.HEIC separately to change them by 180 degrees.  Can you tell me which, if either, of these pictures displays properly:

IMG_6161a.HEIC (https://exiftool.org/tmp/IMG_6161a.HEIC)

IMG_6161b.HEIC (https://exiftool.org/tmp/IMG_6161b.HEIC)

- Phil
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: wywh on March 10, 2025, 02:17:10 AM
Quote from: Phil Harvey on March 09, 2025, 09:18:17 PMwhich, if either, of these pictures displays properly
Both open OK in macOS 15.3.1 Sequoia Intel QuickLook and Preview.app in portrait mode, IMG_6161b.HEIC is correctly orientated, IMG_6161a.HEIC is upside down.

p.s. GraphicConverter 12.3.1 Browser displays IMG_6161b.HEIC OK, IMG_6161a.HEIC thumbnail is upside down and the main GC window briefly displays it upside down before displaying it correctly.

p.p.s. While testing otherwise OK iPhone 16 Pro .heic images I deliberately wrote different orientation to QuickTime:Rotation, IFD0:Orientation and XMP-tiff:Orientation to check what tag was preferred in some apps:

macOS Sequoia 15 QuickLook and Preview.app and Photoshop 2025 use the Rotation tag for the image display for .heic.

GraphicConverter Browser uses Rotation tag for .heic in its thumbnail display and very briefly in its main display before reverting using Orientation XMP-tiff:Orientation or preferably IFD0:Orientation tag if those differ.

In .jpg GC prefers IFD0:Orientation over XMP-tiff:Orientation if they differ. If there is only XMP-tiff:Orientation, then Browser thumbnails displays it and the main display displays it only briefly. I might nag GC author about this later.
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: wywh on March 10, 2025, 03:09:33 AM
I have a few iPhone 16 Pro iOS 18.2 .heic images and one of them that was shot in portrait mode has the same issue.

(I guess all rotations were done automatically inside the iPhone while shooting and no manual rotations were done. GraphicConverter might have created XMP-tiff:Orientation while editing other tags).

All landscape .heic have one Rotation tag but the portrait .heic has two:

exiftool -a -G1 -s -fileOrder5 FileName -Rotation -Orientation .
======== ./landscape.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)
[XMP-tiff]      Orientation                     : Horizontal (normal)
======== ./portrait.heic
[QuickTime]     Rotation                        : Rotate 90 CW
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Rotate 90 CW
[XMP-tiff]      Orientation                     : Rotate 90 CW

Rotating works as expected in the landscape .heic but makes the portrait .heic unreadable in QuickLook, Preview.app, GraphicConverter and Photoshop 2025:

exiftool -Rotation='Rotate 270 CW' -Orientation='Rotate 270 CW' .

exiftool -a -G1 -s -fileOrder5 FileName -Rotation -Orientation .
======== ./landscape.heic
[QuickTime]     Rotation                        : Rotate 270 CW
[IFD0]          Orientation                     : Rotate 270 CW
[XMP-tiff]      Orientation                     : Rotate 270 CW
======== ./portrait.heic
[QuickTime]     Rotation                        : Rotate 270 CW
[IFD0]          Orientation                     : Rotate 270 CW
[XMP-tiff]      Orientation                     : Rotate 270 CW

- Matti
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: wywh on March 10, 2025, 03:45:52 AM
I did some more tests with those iPhone 16 Pro iOS 18.2 .heic images by rotating them in Apple's Sequoia apps.

-> Maybe there is an error how exiftool calculates Rotation tag? Unlike movies, .heic does not seem to have QuickTime:MatrixStructure tag.

Rotating 90° CCW via QuickLook initially seems to work for landscape, but the .heic is not really rotated so the next time QuickLook displays it is still in landscape anyway.

On the other hand, QuickLook successfully rotates 90° CCW the portrait .heic and in the process deletes the duplicate Rotation tag and XMP-tiff:Orientation. It is still readable in all apps:

exiftool -a -G1 -s -fileOrder5 FileName -Rotation -Orientation .
======== ./landscape.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)
[XMP-tiff]      Orientation                     : Horizontal (normal)
======== ./portrait.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Rotate 90 CW

But re-rotating in QuickLook does not always stick, and even if it sticks and orient differently in display, the tags exiftool displays are not changed and stay the same as above. Very weird.

Rotating 90° CCW in Preview.app succeeds for landscape and portrait but confusingly landscape tags stay the same although it is then displayed in portrait mode:

exiftool -a -G1 -s -fileOrder5 FileName -Rotation -Orientation .
======== ./landscape.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)
======== ./portrait.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)

Re-rotating 90° CCW in Preview.app makes both to display upside down as expected but the tags are still the same. Very confusing.

exiftool -a -G1 -s -fileOrder5 FileName -Rotation -Orientation .
======== ./landscape.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)
======== ./portrait.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)

- Matti
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: SebC on March 10, 2025, 06:11:21 AM
Hello all,

Quote from: Phil Harvey on March 09, 2025, 09:18:17 PMActually, I've quickly hacked each of the two rotation tags of your IMG_6161.HEIC separately to change them by 180 degrees.  Can you tell me which, if either, of these pictures displays properly:
IMG_6161a.HEIC (https://exiftool.org/tmp/IMG_6161a.HEIC)
IMG_6161b.HEIC (https://exiftool.org/tmp/IMG_6161b.HEIC)

- Phil

@Phil : as Matti said, both open fine, IMG_6161a.HEIC is upside down (so rotation was applied correctly) and IMG_6161b.HEIC is identical to the initial image IMG_6161.HEIC.


Quote from: wywh on March 10, 2025, 03:09:33 AMRotating works as expected in the landscape .heic but makes the portrait .heic unreadable in QuickLook, Preview.app, GraphicConverter and Photoshop 2025:

Oops, I was not expecting the behavior to change depending on the orientation of the original photo ... I can provide more sample pics in landscape format :
- IMG_6141.HEIC : iphone 16 landscape picture
- IMG_E6141.HEIC : iphone 16 landscape picture rotated 180° directly in the iphone
(sorry to ask, but how can I upload a file in an opened thread on Exiftool forum ?)

thanks,
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: wywh on March 10, 2025, 06:37:48 AM
Quote from: SebC on March 10, 2025, 06:11:21 AMhow can I upload a file in an opened thread on Exiftool forum ?
I guess you have to click the REPLY button, and then "Click and drag files here to attach them" under the reply dialog to do that. It seems the more readily available "Quick Reply" or replying via "Quoted text" does not allow attaching files.
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: SebC on March 10, 2025, 07:06:43 AM
Quote from: wywh on March 10, 2025, 06:37:48 AMIt seems the more readily available "Quick Reply" or replying via "Quoted text" does not allow attaching files.
Yes, indeed ... thanks for pointing out.

So here are the files.
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: Phil Harvey on March 10, 2025, 08:16:55 AM
OK.  I have a version that needs to be tested.  I wasn't sure what O/S everyone is using so I prepared a pre-release of all packages:

ExifTool-13.25p.pkg (https://exiftool.org/ExifTool-13.25p.pkg)
Image-ExifTool-13.25p.tar.gz (https://exiftool.org/Image-ExifTool-13.25p.tar.gz)
exiftool-13.25p_64.zip (https://exiftool.org/exiftool-13.25p_64.zip)
exiftool-13.25p_32.zip (https://exiftool.org/exiftool-13.25p_32.zip)

Let me know how this works for writing Rotation to these HEIC images.

TIA for your help.

- Phil
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: SebC on March 10, 2025, 12:28:37 PM
Hello Phil,

I tested 13.25 and it is almost perfect, i.e. all commands "exiftool -rotation=nnn IMG_xxxx.HEIC" work like a charm (i.e. rotate photo and the output is readable), except when rotation angle is 0.

exiftool -rotation=90 IMG_6161.HEIC
    1 image files updated

exiftool -rotation=180 IMG_6161.HEIC
    1 image files updated

exiftool -rotation=270 IMG_6161.HEIC
    1 image files updated

exiftool -rotation=0 IMG_6161.HEIC
    0 image files updated
    1 image files unchanged

I've attached -v3 debug command outputs for rotation = 0 and 90.
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: wywh on March 10, 2025, 12:36:23 PM
13.25 (pre-release) works better but not perfectly. I try to explain:

I could set all those test landscape and portrait images correctly by the following commands. Also 'Rotate 270 CW', 'Rotate 180' and 'Rotate 90 CW' as well as the numeric commands work as expected.

-> But bringing Preview.app rotations to the mix puts this very confusingly out-of-sync, see below.

exiftool -m -P -overwrite_original -Rotation='Horizontal (normal)' -Orientation='Horizontal (normal)' landscape*

exiftool -m -P -overwrite_original -Rotation='Rotate 90 CW' -Orientation='Rotate 90 CW' portrait*

exiftool -a -G1 -s -fileOrder5 FileName -Rotation -Orientation .

======== ./landscape.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)
[XMP-tiff]      Orientation                     : Horizontal (normal)
======== ./landscape_IMG_6141.HEIC
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)

======== ./portrait.heic
[QuickTime]     Rotation                        : Rotate 90 CW
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Rotate 90 CW
[XMP-tiff]      Orientation                     : Rotate 90 CW
======== ./portrait_IMG_5588.HEIC
[QuickTime]     Rotation                        : Rotate 90 CW
[IFD0]          Orientation                     : Rotate 90 CW
======== ./portrait_IMG_6161.HEIC
[QuickTime]     Rotation                        : Rotate 90 CW
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Rotate 90 CW

Only the images that were edited in the iPhone (marked by E) were incorrect:

======== ./landscape_IMG_E6141.HEIC <-<- upside down
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)

======== ./portrait_IMG_E6161.HEIC <-<- upside down 90° CCW
[QuickTime]     Rotation                        : Rotate 90 CW
[IFD0]          Orientation                     : Rotate 90 CW

I could not reset the to follow the rules via exiftool. But after I rotated them via Preview.app to their neutral position (landscape horizontal, portrait 90° CCW), then they followed exiftool rotations unless Preview broke the sync.

The following are my test images that were not previously manually rotated. I wonder why the portrait image has Rotation tag twice, maybe by design?

exiftool -a -G1 -s -fileOrder5 FileName -Rotation -Orientation .           
======== ./landscape.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)
[XMP-tiff]      Orientation                     : Horizontal (normal)
======== ./portrait.heic
[QuickTime]     Rotation                        : Rotate 90 CW
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Rotate 90 CW
[XMP-tiff]      Orientation                     : Rotate 90 CW

If I use Apple's Preview.app to rotate both 90° CCW exiftool reads them as follows but no matter how many times I re-do the rotation to some another position exiftool still displays the following info despite all apps display the images rotated in various positions.

I can then apply rotation via exiftool but then the image position is out-of-sync until I fiddle with Preview rotations them to those neutral positions.

exiftool -a -G1 -s -fileOrder5 FileName -Rotation -Orientation .
======== ./landscape.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)
======== ./portrait.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)

- Matti
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: wywh on March 10, 2025, 12:59:00 PM
As a side note this got me confused when testing. Starting point:

exiftool -a -G1 -s -n -Rotation -Orientation landscape.heic
[QuickTime]     Rotation                        : 3
[IFD0]          Orientation                     : 6
[XMP-tiff]      Orientation                     : 6

Then try to write numeric values. Despite forgetting to use -n it succeeds but writes wrong values without warnings:

exiftool -Rotation=0 -Orientation=1 landscape.heic   
    1 image files updated

exiftool -a -G1 -s -n -Rotation -Orientation landscape.heic
[QuickTime]     Rotation                        : 3
[IFD0]          Orientation                     : 3
[XMP-tiff]      Orientation                     : 3
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: Phil Harvey on March 10, 2025, 01:27:15 PM
Hi Matti,

Thanks for running some tests, however you have managed to confuse me thoroughly.

I've compared the images IMG_6161.HEIC and IMG_E6161.HEIC (picture rotated by the iPhone), so I think that the image data itself has been rotated.  Does this explain the differences you are seeing?

Also, using -G3:1 would help clear because with the new pre-release version only one Rotation tag should be associated with the main image. 

For reference, below is a data map of an HEIC image that I made a while ago.  The "Rotation" tag is stored in the 'irot' box.  For this image there are 4 objects that refer to the same 'irot' box (the main full-sized 'grid', the preview-sized 'grid', the thumbnail 'hvc1', and the 'tmap').

(https://exiftool.org/pics/heic_map.png)

IMG_6161.HEIC is substantially more complicated.  (Maybe I'll make a map of this if I have the time.)  For this image, there are 9 objects that refer to 'irot' boxes.  8 of these refer to the same 'irot' as the primary image -- this is the 'irot' that the ExifTool 13.25 pre-release writes.  The last 'irot' refers to the 'tmap' image.  Here is a quick breakdown:

ID  Type  'ispe'    'irot'  MIME
--- ------ --------- ------ ------
 46 'grid' 5712x4284  3     (primary item)
 62 'grid' 2856x2142  3     hdrgainmap
 63 'hvc1' 1024x768   3     linearthumbnail
 64 'hvc1' 2016x1512  3     semanticskinmatte
 66 'hvc1' 2016x1512  3     semanticskymatte
 68 'hvc1' 2016x1512  3     portraiteffectsmatte
 70 'hvc1' 416x312    3
119 'grid' 4096x3072  3     styledeltamap
122 'tmap' 4284x5712  0

- Phil
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: wywh on March 10, 2025, 02:00:43 PM
Quote from: Phil Harvey on March 10, 2025, 01:27:15 PMThanks for running some tests, however you have managed to confuse me thoroughly.
Yes, I was afraid the report would be confusing to read. In some images the data itself might have been rotated so it is best to check plain vanilla images from the iPhone. Below are two such iPhone 16 Pro images which apps display correctly, here with G3:1 switch:

exiftool -a -G3:1 -s -Rotation -Orientation .
======== ./landscape.heic
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)
[XMP-tiff]      Orientation                     : Horizontal (normal)
======== ./portrait.heic
[QuickTime]     Rotation                        : Rotate 90 CW
[Doc14:QuickTime] Rotation                      : Horizontal (Normal)
[IFD0]          Orientation                     : Rotate 90 CW
[XMP-tiff]      Orientation                     : Rotate 90 CW

- Matti
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: Phil Harvey on March 10, 2025, 04:11:18 PM
Hi Matti,

Thanks.  So my supposition is not refuted?  (ie. ExifTool is rotating things correctly, and Apple utilities rotate the actual data?)

BTW, here is a map of the objects (black) and their properties (red) in IMG_6161.HEIC.  If you look carefully you can see the two 'irot' objects with differing rotation values.  Note that when ExifTool 13.25p rotates the image, it changes only the value stored in the 'irot' referenced by the primary image (46 grid in this case), so all other objects also using this property will be affected.  If the HEIC format seems like a pain in the ass... It is.

(https://exiftool.org/pics/heic_map2.png)

PH Edit: Updated HEIC map to show where ExifTool will add the top-level XMP.

- Phil
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: wywh on March 11, 2025, 06:01:49 AM
Quote from: Phil Harvey on March 10, 2025, 04:11:18 PMExifTool is rotating things correctly
Yes, 13.25 (pre-release) seems to work correctly. It does not fix .heic that was rendered unreadable in older version, though.

I should have paid attention also to File:ImageWidth and File:ImageHeight when rotating via Preview.app which rotates data itself so File:ImageWidth and File:ImageHeight change places after 90° rotations and where Rotation & Orientation metadata is then always set to Horizontal (normal). GraphicConverter behaves the same. Sorry for the confusion.

Like exiftool, macOS Sequoia QuickLook or Quick Actions > Rotate Left rotate metadata but they are very flaky in doing so and the edited orientation very often fails to really stick in that iPhone 16 .heic. In older .heic and .jpg and movies they work OK and I often use QuickLook to losslessly rotate movies.

I tried to do a more thorough and hopefully not so confusing test:

As an example iPhone 16 IMG_6161.HEIC from the OP's message which displays correctly in portrait mode:

exiftool -a -G3:1 -s -ImageWidth -ImageHeight -Rotation -Orientation IMG_6161.HEIC
[File]          ImageWidth                      : 5712
[File]          ImageHeight                     : 4284
[QuickTime]     Rotation                        : Rotate 90 CW
[Doc10:QuickTime] Rotation                      : Horizontal (Normal)
[IFD0]          Orientation                     : Rotate 90 CW

...set the tags Horizontal (Portrait image tilted 90° to the left):

exiftool -m -P -overwrite_original -Rotation='Horizontal (normal)' -Orientation='Horizontal (normal)' IMG_6161.HEIC

exiftool -a -G3:1 -s -ImageWidth -ImageHeight -Rotation -Orientation IMG_6161.HEIC
[File]          ImageWidth                      : 5712
[File]          ImageHeight                     : 4284
[QuickTime]     Rotation                        : Horizontal (Normal)
[Doc10:QuickTime] Rotation                      : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)

...and back back to the 90° CW correct portrait position:

exiftool -m -P -overwrite_original -Rotation='Rotate 90 CW' -Orientation='Rotate 90 CW' IMG_6161.HEIC

exiftool -a -G3:1 -s -ImageWidth -ImageHeight -Rotation -Orientation IMG_6161.HEIC                   
[File]          ImageWidth                      : 5712
[File]          ImageHeight                     : 4284
[QuickTime]     Rotation                        : Rotate 90 CW
[Doc10:QuickTime] Rotation                      : Horizontal (Normal)
[IFD0]          Orientation                     : Rotate 90 CW

Then via Preview.app Rotate the portrait image 360° back to correct portrait position. It rotates data and drops off Doc10:QuickTime:Rotation while doing so:

exiftool -a -G3:1 -s -ImageWidth -ImageHeight -Rotation -Orientation IMG_6161.HEIC
[File]          ImageWidth                      : 4284
[File]          ImageHeight                     : 5712
[QuickTime]     Rotation                        : Horizontal (Normal)
[IFD0]          Orientation                     : Horizontal (normal)

- Matti
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: Phil Harvey on March 11, 2025, 07:56:24 AM
Hi Matti,

Thanks.  Yes, ExifTool 13.24 and earlier deleted the duplicate Rotation tag when writing (without re-ordering the object properties, which was bad, and the reason it corrupted these images).  The new version won't fix images that have been previously corrupted in this way.

Rotating with Apple utilities (at least with the iPhone-rotated image posted here) not only deletes the duplicate Rotation tag (however it properly re-orders the object properties), but also it deletes many of the embedded images as well as manipulating the image data as we discussed.

I've just released 13.25 officially, and older versions should not be used to rotate these newer HEIC images.

Thanks to SebC for reporting this issue, and for the samples.

- Phil
Title: Re: Rotation / Orientation of iphone HEIC files
Post by: SebC on March 11, 2025, 03:03:46 PM
Hello Phil,

Thanks for the great help, and thanks also Matti for the extensive testing and help.
I'll spend some time this week-end to test various configurations (horizontal / vertical pics, then various rotation / orientation settings) and see what happens.

Thanks all and take care !
Sébastien