Extracting auxiliary image from an iPhone HEIC

Started by 92385, May 02, 2023, 05:09:44 PM

Previous topic - Next topic

92385

Some iPhone HEIC images contain a reference to an auxiliary image. However, I do not see any suitable tags (using exiftool -s) to extract a secondary image (using something like exiftool -MPImage2 -b). How can one actually extract such a secondary image?

Potentially relevant metadata from my test image:
ExifToolVersion                : 12.54
FileSize                        : 488 kB
MIMEType                        : image/heic
MetaImageSize                  : 4032x3024
HDRGainMapVersion              : 65536
Make                            : Apple
Model                          : iPhone 14 Pro
HDRHeadroom                    : 0.6844365003
HDRGain                        : 0.4253954589
Format                          : image/heic
Version                        : 15.3
ProcessVersion                  : 11.0
ImagePixelDepth                : 8
AuxiliaryImageType              : urn:com:apple:photo:2020:aux:hdrgainmap

Phil Harvey

ExifTool only extracts embedded images if they are self-contained files.  I doubt this is the case for these images, but you can use the -v3 option to see details about what is stored in the file and how

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

92385

#2
Thank you, Phil. I've pulled that -v3 data, but am not sure how to interpret it. Below are segments which seem potentially relevant. Does the info around "AuxiliaryImageType" means something to you?

  | | ThumbnailRef = 2.1
  | | - Tag 'thmb' (6 bytes):
  | |    74540: 00 32 00 01 00 31                              [.2...1]
  | |  Item 50 refers to: 49
  | | AuxiliaryImageRef = 3.1
  | | - Tag 'auxl' (6 bytes):
  | |    7454e: 00 33 00 01 00 31                              [.3...1]
  | |  Item 51 refers to: 49

  | Item 52) 'application/rdf+xml' (363 bytes)
  |    2c1d: 3c 78 3a 78 6d 70 6d 65 74 61 20 78 6d 6c 6e 73 [<x:xmpmeta xmlns]
  |    2c2d: 3a 78 3d 22 61 64 6f 62 65 3a 6e 73 3a 6d 65 74 [:x="adobe:ns:met]
  |    2c3d: 61 2f 22 20 78 3a 78 6d 70 74 6b 3d 22 58 4d 50 [a/" x:xmptk="XMP]
  |    2c4d: 20 43 6f 72 65 20 36 2e 30 2e 30 22 3e 0a 20 20 [ Core 6.0.0">.  ]
  |    2c5d: 20 3c 72 64 66 3a 52 44 46 20 78 6d 6c 6e 73 3a [ <rdf:RDF xmlns:]
  |    2c6d: 72 64 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e [rdf="http://www.]
  |    [snip 267 bytes]
  | + [XMP directory, 363 bytes]
  | | XMPToolkit = XMP Core 6.0.0
  | | [adding XMP-HDRGainMap:HDRGainMapVersion]
  | | HDRGainMapVersion = 65536
  | | - Tag 'x:xmpmeta/rdf:RDF/rdf:Description/HDRGainMap:HDRGainMapVersion'


  | Item 54) 'application/rdf+xml' (8006 bytes)
  |    75222: 3c 3f 78 70 61 63 6b 65 74 20 62 65 67 69 6e 3d [<?xpacket begin=]
  |    75232: 22 ef bb bf 22 20 69 64 3d 22 57 35 4d 30 4d 70 ["..." id="W5M0Mp]
  |    75242: 43 65 68 69 48 7a 72 65 53 7a 4e 54 63 7a 6b 63 [CehiHzreSzNTczkc]
  |    75252: 39 64 22 3f 3e 0a 3c 78 3a 78 6d 70 6d 65 74 61 [9d"?>.<x:xmpmeta]
  |    75262: 20 78 6d 6c 6e 73 3a 78 3d 22 61 64 6f 62 65 3a [ xmlns:x="adobe:]
  |    75272: 6e 73 3a 6d 65 74 61 2f 22 20 78 3a 78 6d 70 74 [ns:meta/" x:xmpt]
  |    [snip 7910 bytes]




  | | 10) ImageSpatialExtent = ....
  | |    - Tag 'ispe' (12 bytes):
  | |        74d05: 00 00 00 00 00 00 07 e0 00 00 05 e8            [............]
  | | 11) ImagePixelDepth = ..
  | |    - Tag 'pixi' (6 bytes):
  | |        74d19: 00 00 00 00 01 08                              [......]
  | | 12) AuxiliaryImageType = urn:com:apple:photo:2020:aux:hdrgainmap
  | |    - Tag 'auxC' (44 bytes, undef):
  | |        74d27: 00 00 00 00 75 72 6e 3a 63 6f 6d 3a 61 70 70 6c [....urn:com:appl]
  | |        74d37: 65 3a 70 68 6f 74 6f 3a 32 30 32 30 3a 61 75 78 [e:photo:2020:aux]
  | |        74d47: 3a 68 64 72 67 61 69 6e 6d 61 70 00            [:hdrgainmap.]
  MediaDataSize = 8006
  MediaDataOffset = 479778
  MediaData = <?xpacket begin="..." id="W5M0MpCehiHzreSzNTczkc9d"?>.<x:xmpmeta xmlns:x=[snip]
  - Tag 'mdat' (8006 bytes):
    75222: 3c 3f 78 70 61 63 6b 65 74 20 62 65 67 69 6e 3d [<?xpacket begin=]
    75232: 22 ef bb bf 22 20 69 64 3d 22 57 35 4d 30 4d 70 ["..." id="W5M0Mp]
    75242: 43 65 68 69 48 7a 72 65 53 7a 4e 54 63 7a 6b 63 [CehiHzreSzNTczkc]
    75252: 39 64 22 3f 3e 0a 3c 78 3a 78 6d 70 6d 65 74 61 [9d"?>.<x:xmpmeta]
    75262: 20 78 6d 6c 6e 73 3a 78 3d 22 61 64 6f 62 65 3a [ xmlns:x="adobe:]
      [snip 7926 bytes]
+ [Binary PLIST directory]
+ [Binary PLIST directory]
+ [Binary PLIST directory]
+ [Binary PLIST directory]

Phil Harvey

The metadata for the HDR gain maps is in items 52 and 54.  You would have to see what items these refer to, but I'm guessing they will eventually refer back to an hvc1-type object, which is HEVC image data and isn't a stand-alone format so it isn't currently extracted by ExifTool.

But I don't currently have an HEIC sample containing a gain map so I can't say for sure.  I you want to send me a sample I'll add it to my collection (philharvey66 at gmail.com).

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