exiftool - repair "apple-fi" XMP namespace

Started by trymeout, April 28, 2021, 11:43:50 PM

Previous topic - Next topic

trymeout

I want to repair the "apple-fi" XMP namespace for all the pictures in a directory. I know by using the dot you can run an exif command on all the files inside a directory but is there a way to only run this command on the jpg files with the "apple-fi" XMP namespace?

I tried this command which someone has posted on reddit but it does not work and suggested I come to this forum for a solution.

Thanks in advanced

Reddit post
https://www.reddit.com/r/linux4noobs/comments/n0r0jq/exiftool_repair_applefi_xmp_namespace/

exiftool -if '$XMP-apple-fi:All' -xmp:all= -tagsfromfile @ -xmp:all -overwrite_original .

StarGeek

In what way did it not work?  What was the output from exiftool? Also, what are you trying to fix?

The one thing I didn't add to that command was the -ext (-extension) option to limit processing to jpgs.  To do that you would add -ext jpg to the command.

That command should re-write the XMP on any file that has XMP-apple-fi tags in it.
"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

trymeout

Quote from: StarGeek on April 29, 2021, 12:41:57 AM
In what way did it not work?  What was the output from exiftool? Also, what are you trying to fix?

The one thing I didn't add to that command was the -ext (-extension) option to limit processing to jpgs.  To do that you would add -ext jpg to the command.

That command should re-write the XMP on any file that has XMP-apple-fi tags in it.

This is the terminal output when running the command in a directory with only two JPG files. One from an apple iphone camera and the other one from a non-iphone camera. It does not fix the iphone JPG file.

$ exiftool -if '$XMP-apple-fi:All' -xmp:all= -tagsfromfile @ -xmp:all -overwrite_original .
    1 directories scanned
    2 files failed condition
    0 image files read
$


StarGeek

Are you sure those files contain XMP-apple-fi tags?  Can you share a sample image?
"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

trymeout

Quote from: StarGeek on April 29, 2021, 11:41:58 AM
Are you sure those files contain XMP-apple-fi tags?  Can you share a sample image?

Here is a download link and an attachment

https://ufile.io/9urlwmmj

StarGeek

Ah, I see now.  The XMP-apple-fi do not exists in a separate namespace and aren't extracted or copied with XMP-apple-fi:All.  They are part of the the MWG region data, using the MWG Extensions Struct.

You can use
-if '$XMP-mwg-rs:All'
to re-write all files that contain the MWG region. Or use something like
-if '$RegionExtensionsAngleInfoRoll'
to target the files that will include the Apple-fi in the extension space.

Looking at the raw XMP, the original file uses the more compact XMP format, while the re-written XMP is more expansive.  For example, the original writes
<mwg-rs:Extensions apple-fi:AngleInfoYaw="0" apple-fi:AngleInfoRoll="0" apple-fi:ConfidenceLevel="693" apple-fi:FaceID="56"/>
while exiftool is writing
      <mwg-rs:Extensions rdf:parseType='Resource'>
       <apple-fi:AngleInfoRoll>0</apple-fi:AngleInfoRoll>
       <apple-fi:AngleInfoYaw>0</apple-fi:AngleInfoYaw>
       <apple-fi:ConfidenceLevel>693</apple-fi:ConfidenceLevel>
       <apple-fi:FaceID>56</apple-fi:FaceID>
      </mwg-rs:Extensions>
"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

trymeout

I tried this command and it seems to work but how do I view the raw XMP of a image?

exiftool -if '$RegionExtensionsAngleInfoRoll' -xmp:all= -tagsfromfile @ -xmp:all -overwrite_original .

StarGeek

Like this
exiftool -XMP -b file.jpg

This uses the -b (-binary) option to extract the data in the XMP tag (see the XMP entry on the Extra tags page).
"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

trymeout

This is the output before

$exiftool -XMP -b facetagsdonotwork.jpg
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0-Exiv2"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:mwg-rs="http://www.metadataworkinggroup.com/schemas/regions/" xmlns:stArea="http://ns.adobe.com/xmp/sType/Area#" xmlns:apple-fi="http://ns.apple.com/faceinfo/1.0/" xmlns:stDim="http://ns.adobe.com/xap/1.0/sType/Dimensions#" xmp:CreatorTool="Photos 3.0"> <mwg-rs:Regions rdf:parseType="Resource"> <mwg-rs:RegionList> <rdf:Seq> <rdf:li> <rdf:Description mwg-rs:Type="Face"> <mwg-rs:Area stArea:y="0.90195837897042697" stArea:w="0.038147783251231526" stArea:x="0.28845320197044333" stArea:h="0.052048192771084301" stArea:unit="normalized"/> <mwg-rs:Extensions apple-fi:AngleInfoYaw="0" apple-fi:AngleInfoRoll="0" apple-fi:ConfidenceLevel="693" apple-fi:FaceID="56"/> </rdf:Description> </rdf:li> <rdf:li> <rdf:Description mwg-rs:Type="Face"> <mwg-rs:Area stArea:y="0.28778970427163186" stArea:w="0.067625615763546781" stArea:x="0.21996059113300498" stArea:h="0.090216867469879503" stArea:unit="normalized"/> <mwg-rs:Extensions apple-fi:AngleInfoYaw="0" apple-fi:AngleInfoRoll="270" apple-fi:ConfidenceLevel="80" apple-fi:FaceID="55"/> </rdf:Description> </rdf:li> <rdf:li> <rdf:Description mwg-rs:Type="Face"> <mwg-rs:Area stArea:y="0.44740416210295725" stArea:w="0.043349753694581272" stArea:x="0.27371428571428569" stArea:h="0.058987951807228933" stArea:unit="normalized"/> <mwg-rs:Extensions apple-fi:AngleInfoYaw="0" apple-fi:AngleInfoRoll="270" apple-fi:ConfidenceLevel="385" apple-fi:FaceID="49"/> </rdf:Description> </rdf:li> </rdf:Seq> </mwg-rs:RegionList> <mwg-rs:AppliedToDimensions stDim:h="3024" stDim:w="4032" stDim:unit="pixel"/> </mwg-rs:Regions> </rdf:Description> </rdf:RDF> </x:xmpmeta>


and this is the output after

$exiftool -XMP -b facetagsdonotwork.jpg
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 11.88'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:apple-fi='http://ns.apple.com/faceinfo/1.0/'
  xmlns:mwg-rs='http://www.metadataworkinggroup.com/schemas/regions/'
  xmlns:stArea='http://ns.adobe.com/xmp/sType/Area#'
  xmlns:stDim='http://ns.adobe.com/xap/1.0/sType/Dimensions#'>
  <mwg-rs:Regions rdf:parseType='Resource'>
   <mwg-rs:AppliedToDimensions rdf:parseType='Resource'>
    <stDim:h>3024</stDim:h>
    <stDim:unit>pixel</stDim:unit>
    <stDim:w>4032</stDim:w>
   </mwg-rs:AppliedToDimensions>
   <mwg-rs:RegionList>
    <rdf:Bag>
     <rdf:li rdf:parseType='Resource'>
      <mwg-rs:Area rdf:parseType='Resource'>
       <stArea:h>0.052048192771084301</stArea:h>
       <stArea:unit>normalized</stArea:unit>
       <stArea:w>0.038147783251231526</stArea:w>
       <stArea:x>0.28845320197044333</stArea:x>
       <stArea:y>0.90195837897042697</stArea:y>
      </mwg-rs:Area>
      <mwg-rs:Extensions rdf:parseType='Resource'>
       <apple-fi:AngleInfoRoll>0</apple-fi:AngleInfoRoll>
       <apple-fi:AngleInfoYaw>0</apple-fi:AngleInfoYaw>
       <apple-fi:ConfidenceLevel>693</apple-fi:ConfidenceLevel>
       <apple-fi:FaceID>56</apple-fi:FaceID>
      </mwg-rs:Extensions>
      <mwg-rs:Type>Face</mwg-rs:Type>
     </rdf:li>
     <rdf:li rdf:parseType='Resource'>
      <mwg-rs:Area rdf:parseType='Resource'>
       <stArea:h>0.090216867469879503</stArea:h>
       <stArea:unit>normalized</stArea:unit>
       <stArea:w>0.067625615763546781</stArea:w>
       <stArea:x>0.21996059113300498</stArea:x>
       <stArea:y>0.28778970427163186</stArea:y>
      </mwg-rs:Area>
      <mwg-rs:Extensions rdf:parseType='Resource'>
       <apple-fi:AngleInfoRoll>270</apple-fi:AngleInfoRoll>
       <apple-fi:AngleInfoYaw>0</apple-fi:AngleInfoYaw>
       <apple-fi:ConfidenceLevel>80</apple-fi:ConfidenceLevel>
       <apple-fi:FaceID>55</apple-fi:FaceID>
      </mwg-rs:Extensions>
      <mwg-rs:Type>Face</mwg-rs:Type>
     </rdf:li>
     <rdf:li rdf:parseType='Resource'>
      <mwg-rs:Area rdf:parseType='Resource'>
       <stArea:h>0.058987951807228933</stArea:h>
       <stArea:unit>normalized</stArea:unit>
       <stArea:w>0.043349753694581272</stArea:w>
       <stArea:x>0.27371428571428569</stArea:x>
       <stArea:y>0.44740416210295725</stArea:y>
      </mwg-rs:Area>
      <mwg-rs:Extensions rdf:parseType='Resource'>
       <apple-fi:AngleInfoRoll>270</apple-fi:AngleInfoRoll>
       <apple-fi:AngleInfoYaw>0</apple-fi:AngleInfoYaw>
       <apple-fi:ConfidenceLevel>385</apple-fi:ConfidenceLevel>
       <apple-fi:FaceID>49</apple-fi:FaceID>
      </mwg-rs:Extensions>
      <mwg-rs:Type>Face</mwg-rs:Type>
     </rdf:li>
    </rdf:Bag>
   </mwg-rs:RegionList>
  </mwg-rs:Regions>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:xmp='http://ns.adobe.com/xap/1.0/'>
  <xmp:CreatorTool>Photos 3.0</xmp:CreatorTool>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>


Looks like it works to me and now when I add face tags to these pictures in digikam, the face tags do remain. Thank you for your help, this is going to save me hours of work.

trymeout

It will seem this command is not enough as some face tags will not stay. Here is a sample picture and I did use this command on the image itself and it does not work

exiftool -if '$RegionExtensionsAngleInfoRoll' -xmp:all= -tagsfromfile @ -xmp:all -overwrite_original .

StarGeek

Is that the before or after?  There's no regions in that file at all.  Can't keep what isn't there.
"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

trymeout

I tried to use that image file and add a face tag in it using Digikam 7.2.0 and when I delete the digikam database and readd the directory the image was in, the face tags did not save. I do have the settings enabled to save face tags into the file and not only into the digikam database.

StarGeek

That would be a Digikam question.  I have no idea.
"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