1
$\begingroup$

I used Google Picasa to tag a face in a JPG photo, which is stored as an XMP metadata tag within the photo itself:

enter image description here

Here is a link to the photo. If that URL has expired, you can download the pic as a hexdump from pastebin and reconstruct the JPG like this (on mac/linux):

curl https://pastebin.com/raw/cHVCZu7Z | xxd -r > tmp.jpg

The face information is indeed contained in the file, as a plain text string:

$ strings ~/Desktop/stephen-wolfram-portrait.jpg | grep -i face

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.1.2">
...
<rdf:Description mwg-rs:Name="Stephen Wolfram" mwg-rs:Type="Face"> 
<mwg-rs:Area stArea:x="0.51529" stArea:y="0.194588" stArea:w="0.302752" stArea:h="0.306701" stArea:unit="normalized"/> 
</rdf:Description>
...
</x:xmpmeta>

Indeed, the same information can be parsed more cleanly using Phil Harvey's excellent ExifTool:

$ ./exiftool ~/Desktop/stephen-wolfram-portrait.jpg

...
Region Applied To Dimensions W  : 327
Region Applied To Dimensions H  : 388
Region Applied To Dimensions Unit: pixel
Region Name                     : Stephen Wolfram
Region Type                     : Face
Region Area X                   : 0.51529
Region Area Y                   : 0.194588
Region Area W                   : 0.302752
Region Area H                   : 0.306701
Region Area Unit                : normalized

However, this information doesn't appear when I import the XMP metadata using Mathematica:

Import["~/Desktop/stephen-wolfram-portrait.jpg","RawXMP"]

<| 
    DocumentID -> xmp.did:F13E3BFC48A911E795D0ECF78D2F4D6F,
    InstanceID -> xmp.iid:F13E3BFB48A911E795D0ECF78D2F4D6F,
    OriginalDocumentID -> xmp.did:fe3d7bde-47fb-4e33-90ba-85337d7f6aae,
    DerivedFrom -> type= Struct ,
    DerivedFrom/stRef:instanceID -> xmp.iid:78f88771-4e7b-4513-9fd2-f084264b8861,
    DerivedFrom/stRef:documentID -> adobe:docid:photoshop:64644718-9012-117a-8583-a9a1e6363c97,
    CreatorTool -> Adobe Photoshop CC 2017 (Macintosh),
    ModifyDate -> 2019-06-01T06:51:30-07:00
|>



Import["~/Desktop/stephen-wolfram-portrait.jpg","XMP"]


<| 
    BasicSchema -> <|
        CreatorTool -> Adobe Photoshop CC 2017 (Macintosh), 
        ModifyDate -> Sat 1 Jun 2019 06:51:30GMT-7.
        |>, 
    MediaManagementSchema -> <|
        DerivedFrom -> <|
            DerivedFrom -> <|
                InstanceID -> xmp.iid:78f88771-4e7b-4513-9fd2-f084264b8861, 
                DocumentID -> adobe:docid:photoshop:64644718-9012-117a-8583-a9a1e6363c97
            |>
        |>, 
        DocumentID -> xmp.did:F13E3BFC48A911E795D0ECF78D2F4D6F, 
        InstanceID -> xmp.iid:F13E3BFB48A911E795D0ECF78D2F4D6F, 
        OriginalDocumentID -> xmp.did:fe3d7bde-47fb-4e33-90ba-85337d7f6aae
    |>, 
    RightsManagementSchema -> <|
        DerivedFrom -> <|
            DerivedFrom -> <|
                InstanceID -> xmp.iid:78f88771-4e7b-4513-9fd2-f084264b8861, 
                DocumentID -> adobe:docid:photoshop:64644718-9012-117a-8583-a9a1e6363c97
            |>
        |>
    |>, 
    PagedTextSchema -> <|
        DerivedFrom -> <|
            DerivedFrom -> <|
                InstanceID -> xmp.iid:78f88771-4e7b-4513-9fd2-f084264b8861, 
                DocumentID -> adobe:docid:photoshop:64644718-9012-117a-8583-a9a1e6363c97
            |>
        |>
    |>
|>

Is there a natural way to get Mathematica to import this XML metadata?

$\endgroup$
  • $\begingroup$ Can you add a link to the photo with the metadata? $\endgroup$ – M.R. Jun 4 at 5:47
  • $\begingroup$ Done! $\endgroup$ – ConvexMartian Jun 4 at 15:17
  • $\begingroup$ And I added a longer-lasting URL for the pic too, because the link from send.firefox.com expires after a week or 100 downloads. $\endgroup$ – ConvexMartian Jun 4 at 15:37
  • $\begingroup$ Looks like it might be a bug to me, report it to WRI. $\endgroup$ – M.R. Jun 4 at 17:45
  • $\begingroup$ Okay, I'll report it! $\endgroup$ – ConvexMartian Jun 5 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.