xpacket validation check: HEIC vs JPG

Started by Invindicator, May 11, 2025, 10:54:06 AM

Previous topic - Next topic

Invindicator

Hi there,
I'm looking to start using HEIC images over JPGs and was doing some tests with images from my iPhone 12.
I copied the same file twice to the PC, once as a JPG and once as a HEIC.
This was using the built in setting for transferring photos: Automatic (JPG) vs Keep Originals (HEIC).

When I run exiftool with the validate command on both files:

E:\> exiftool -validate -warning -error -a "HEIC IMAGE TEST.HEIC" IMG_1305.JPG

======== HEIC IMAGE TEST.HEIC
Validate                        : OK
======== IMG_1305.JPG
Validate                        : 2 Warnings (1 minor)
Warning                         : [minor] XMP is missing xpacket wrapper
Warning                         : Missing required JPEG GPS tag 0x0000 GPSVersionID
  • The HEIC image passes. I get an OK status.
  • The JPG image gives a minor error that the xpacket wrapper is missing for the XMP data.

I can see the xpacket wrapper for the JPG after re-writing the XMP data with exiftool
exiftool -r -ext heic -ext jpg -if "($XMP:All)" -XMP:All= -TagsFromFile @ -XMP:All -XMP:XMPToolkit .This isn't the case with HEIC and the wrapper isn't applied.

Is the wrapper not required on HEIC images? Or are there different XMP segments within the metadata and it is not required for all of them?

As an aside, does anyone know of a way to rotate the raw HEIC image data? I.e. physically rotate the image based on the orientation/rotation tags so it is always orientated in the correct direction. I used to do this for the JPG images using this tool here https://savolai.net/software/jpeg-autorotate/. This way images would be guaranteed to show correctly, especially on things like digital photo frames.

Cheers, Nick

StarGeek

I can't really comment on the first part without seeing some files. Phil probably could without seeing the files, but I suspect he's experiencing good weather and is semi-AFK.

But as for rotation, I don't believe it's possible to losslessly rotate the image data. HEIC is based upon MP4 file format and is different from the JPEG format. Editing the Rotation tag seems to be the best solution, as not everything will properly honor the EXIF:Rotation tag.
"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

wywh

Quote from: Invindicator on May 11, 2025, 10:54:06 AMrotate the raw HEIC image data

FWIW Mac Preview.app and GraphicConverter rotate (also the new slightly different iOS/iPadOS 18) .heic data itself and set Rotation & Orientation metadata to Horizontal (normal).

https://exiftool.org/forum/index.php?topic=17169.msg91984#msg91984

- Matti

StarGeek

Is it a lossless rotation? Can you provide me with a couple images (one original, one rotated) so I can compare?
"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

The HEIC doesn't give this warning because as far as I know the XMP specification has not yet specified how this should be stored in HEIC.

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

wywh

Quote from: StarGeek on May 11, 2025, 03:27:55 PMIs it a lossless rotation? Can you provide me with a couple images (one original, one rotated) so I can compare?
Here are iPhone 16 Pro iOS 18.4.1 landscape and portrait .heic images.

Both are then rotated CCW 90° with Sequoia 15.5 Preview.app and GraphicConverter 12.4.

- Matti

StarGeek

Thanks for those.

But it looks like I'll have a problem with the base images. My installed HEIC codec can't read them and ImageMagick returns
C:\>magick mogrify -format png Y:\!temp\x\y\rotate\*.HEIC
mogrify: Invalid input: Unspecified: Too many auxiliary image references (2.0) `Y:\!temp\x\y\rotate\landscape.HEIC' @ error/heic.c/IsHEIFSuccess/135.
...

Off to search for a solution

"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

StarGeek

After updating ImageMagic, I was able to run a compare on the images. The rotation is not a lossless one.

I had to halve the size of the resulting images and save as jpgs, but it's still enough to see the differences. White is where the pixels haven't been changed and red are pixels that have been changed.

landscape_GraphicConverter_difference
landscape_GraphicConverter_difference.jpg

landscape_Preview90CCW_difference
landscape_Preview90CCW_difference.jpg
"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

wywh

#8
Quote from: StarGeek on May 24, 2025, 05:15:12 PMAfter updating ImageMagic, I was able to run a compare on the images. The rotation is not a lossless one.
Thanks for the info. macOS Sequoia 15.5 QuickLook can rotate that new iOS 18 .heic flavor by updating Rotation tag (Orientation tag seems to remain the same). But that is very flaky and very often the last rotation does not stick, especially after doing a different rotation or after 180° rotation to a portrait image.

iOS 18 added some new features to .heic images and HEVC movies. macOS High Sierra 10.13 was the first macOS to support .heic but even that no longer supports the new .heic flavor and you need macOS Mojave 10.14 for that.

Some Windows 10-11 users seem to have issues with the new iOS/iPadOS 18 .heic and HEVC.

Did you have to install any new .heic add-ons for Windows .heic support? Or does Windows 10-11 already have them built-in?

- Matti

StarGeek

Quote from: wywh on May 25, 2025, 02:52:16 AMDid you have to install any new .heic add-ons for Windows .heic support? Or does Windows 10-11 already have them built-in?

I'm still on Win10, which does not have it built in. I'm not sure about Win11, but I don't think it does. Additionally, I try to avoid the MS store, so I installed a 3rd party HEIC codec, which obviously isn't up to the task.

At some point I'll probably be forced to change things, but since I don't personally use HEIC files, I'm not worrying about it at this time.
"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