Fix nonstandard Apple .xmp GPS tags

Started by wywh, June 21, 2023, 05:37:36 AM

Previous topic - Next topic

wywh

macOS 10.15-13 Catalina - Ventura Photos.app ignore the standard for GPS data with its "Export IPTC as XMP" option.

Because of this flaw, western and southern references are ignored if a standard method of copying .xmp sidecar to images and movies is used so Santiago de Chile is put to the other side of the globe in Pakistan. Flawed .xmp looks like this:

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 6.0.0">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about=""
            xmlns:exif="http://ns.adobe.com/exif/1.0/"
            xmlns:dc="http://purl.org/dc/elements/1.1/"
            xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
         <exif:GPSLongitude>70.650466100000003</exif:GPSLongitude>
         <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
         <exif:GPSHPositioningError>1</exif:GPSHPositioningError>
         <exif:GPSLatitude>33.451855799999997</exif:GPSLatitude>
         <exif:GPSLatitudeRef>S</exif:GPSLatitudeRef>
         <exif:GPSTimeStamp>2022-01-07T16:48:10Z</exif:GPSTimeStamp>
         <dc:title>Title Photos 7 åäöÅÄÖ</dc:title>
         <dc:description>Caption Photos 7 åäöÅÄÖ</dc:description>
         <dc:subject>
            <rdf:Seq>
               <rdf:li>Keyword 1 Photos 7 åäöÅÄÖ</rdf:li>
               <rdf:li>Keyword 2 Photos 7 åäöÅÄÖ</rdf:li>
            </rdf:Seq>
         </dc:subject>
         <photoshop:DateCreated>2000-01-01T12:00:00+02:00</photoshop:DateCreated>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>

https://exiftool.org/forum/index.php?topic=12634.msg68327#msg68327

johnrellis posted exiftool command that fixes the flawed .xmp:

https://community.adobe.com/t5/lightroom-classic-discussions/gps-location-imported-from-iphone-has-wrong-hemisphere/m-p/10830107

exiftool \
  '-xmp-exif:gpslongitude<${xmp-exif:gpslongitude#}${xmp-exif:gpslongituderef#}' \
  '-xmp-exif:gpslatitude<${xmp-exif:gpslatitude#}${xmp-exif:gpslatituderef#}' \
  *.xmp

Support for Composite tags makes the command shorter with the same result. GPS references are still preserved as separate tags but that does not seem to matter (?):

exiftool -P -overwrite_original '-Composite:GPSPosition<$XMP:GPSLatitude# $XMP:GPSLatitudeRef, $XMP:GPSLongitude# $XMP:GPSLongitudeRef' *.xmp
After that .xmp looks like this and the standard "DDD,MM.mmk" is used. Is it possible or needed to get rid of those references as separate tags?

<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.60'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

 <rdf:Description rdf:about=''
  xmlns:dc='http://purl.org/dc/elements/1.1/'>
  <dc:description>Caption Photos 7 åäöÅÄÖ</dc:description>
  <dc:subject>
   <rdf:Seq>
    <rdf:li>Keyword 1 Photos 7 åäöÅÄÖ</rdf:li>
    <rdf:li>Keyword 2 Photos 7 åäöÅÄÖ</rdf:li>
   </rdf:Seq>
  </dc:subject>
  <dc:title>Title Photos 7 åäöÅÄÖ</dc:title>
 </rdf:Description>

 <rdf:Description rdf:about=''
  xmlns:exif='http://ns.adobe.com/exif/1.0/'>
  <exif:GPSHPositioningError>1</exif:GPSHPositioningError>
  <exif:GPSLatitude>33,27.111348S</exif:GPSLatitude>
  <exif:GPSLatitudeRef>S</exif:GPSLatitudeRef>
  <exif:GPSLongitude>70,39.027966W</exif:GPSLongitude>
  <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
  <exif:GPSTimeStamp>2022-01-07T16:48:10Z</exif:GPSTimeStamp>
 </rdf:Description>

 <rdf:Description rdf:about=''
  xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>
  <photoshop:DateCreated>2000-01-01T12:00:00+02:00</photoshop:DateCreated>
 </rdf:Description>
</rdf:RDF>
</x:xmpmeta>

Just rebuilding metadata does not work because it uses incorrect references:

exiftool -P -overwrite_original -All= -tagsfromfile @ -All:All *.xmp
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.60'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

 <rdf:Description rdf:about=''
  xmlns:dc='http://purl.org/dc/elements/1.1/'>
  <dc:description>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'>Caption Photos 7 åäöÅÄÖ</rdf:li>
   </rdf:Alt>
  </dc:description>
  <dc:subject>
   <rdf:Bag>
    <rdf:li>Keyword 1 Photos 7 åäöÅÄÖ</rdf:li>
    <rdf:li>Keyword 2 Photos 7 åäöÅÄÖ</rdf:li>
   </rdf:Bag>
  </dc:subject>
  <dc:title>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'>Title Photos 7 åäöÅÄÖ</rdf:li>
   </rdf:Alt>
  </dc:title>
 </rdf:Description>

 <rdf:Description rdf:about=''
  xmlns:exif='http://ns.adobe.com/exif/1.0/'>
  <exif:GPSHPositioningError>1/1</exif:GPSHPositioningError>
  <exif:GPSLatitude>33,27.111348N</exif:GPSLatitude>
  <exif:GPSLongitude>70,39.027966E</exif:GPSLongitude>
  <exif:GPSTimeStamp>2022-01-07T16:48:10Z</exif:GPSTimeStamp>
 </rdf:Description>

 <rdf:Description rdf:about=''
  xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>
  <photoshop:DateCreated>2000-01-01T12:00:00+02:00</photoshop:DateCreated>
 </rdf:Description>
</rdf:RDF>
</x:xmpmeta>

...

If that .xmp flaw is corrected, then the following command can be used to copy .xmp to images (here to both XMP and IPTC, File dates use XMP-photoshop offset so they might be off):

exiftool -m -overwrite_original_in_place -ext jpg -ext heic '-IPTC:CodedCharacterSet=UTF8' -tagsFromFile %d%f.xmp '-AllDates<XMP-photoshop:DateCreated' '-XMP-photoshop:DateCreated<XMP-photoshop:DateCreated' '-EXIF:All<XMP-exif:All' '-GPS:GPSLatitudeRef<Composite:GPSLatitudeRef' '-GPS:GPSLongitudeRef<Composite:GPSLongitudeRef' '-XMP:All<XMP:All' '-IPTC:ObjectName<XMP-dc:Title' '-IPTC:Caption-Abstract<XMP-dc:Description' '-EXIF:ImageDescription<XMP-dc:Description' '-IPTC:Keywords<XMP-dc:Subject' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .
...and to movies. I use '-Keys:GPSCoordinates' because '-GPSCoordinates' defaults to ItemList instead Keys (which works in my apps unlike corresponding ItemList and UserData tags):

exiftool -m -overwrite_original_in_place -api QuickTimeUTC=1 -ext mp4 -ext m4v -ext mov -tagsFromFile %d%f.xmp -api QuickTimeUTC=1 '-AllDates<XMP-photoshop:DateCreated' '-Track*Date<XMP-photoshop:DateCreated' '-Media*Date<XMP-photoshop:DateCreated' '-Keys:CreationDate<XMP-photoshop:DateCreated' '-Keys:GPSCoordinates<$XMP:GPSLatitude#, $XMP:GPSLongitude#' '-Keys:Title<XMP-dc:Title' '-Keys:Description<XMP-dc:Description' '-Keys:Keywords<XMP-dc:Subject' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .
...

With the flawed unfixed .xmp I have used this workaround with images:

exiftool -m -overwrite_original_in_place -ext jpg -ext heic '-IPTC:CodedCharacterSet=UTF8' -tagsFromFile %d%f.xmp '-AllDates<XMP-photoshop:DateCreated' '-XMP-photoshop:DateCreated<XMP-photoshop:DateCreated' '-GPS:All<XMP-exif:All' '-XMP-dc:All<XMP-dc:All' '-IPTC:ObjectName<XMP-dc:Title' '-IPTC:Caption-Abstract<XMP-dc:Description' '-EXIF:ImageDescription<XMP-dc:Description' '-IPTC:Keywords<XMP-dc:Subject' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .
...and to movies:

exiftool -m -overwrite_original_in_place -api QuickTimeUTC=1 -ext mp4 -ext m4v -ext mov -tagsFromFile %d%f.xmp -api QuickTimeUTC=1 '-AllDates<XMP-photoshop:DateCreated' '-Track*Date<XMP-photoshop:DateCreated' '-Media*Date<XMP-photoshop:DateCreated' '-Keys:CreationDate<XMP-photoshop:DateCreated' '-Keys:GPSCoordinates<$XMP:GPSLatitude# $XMP:GPSLatitudeRef, $XMP:GPSLongitude# $XMP:GPSLongitudeRef' '-Keys:Title<XMP-dc:Title' '-Keys:Description<XMP-dc:Description' '-Keys:Keywords<XMP-dc:Subject' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .
- Matti

Phil Harvey

Quote from: wywh on June 21, 2023, 05:37:36 AMexiftool \
  '-xmp-exif:gpslongitude<${xmp-exif:gpslongitude#}${xmp-exif:gpslongituderef#}' \
  '-xmp-exif:gpslatitude<${xmp-exif:gpslatitude#}${xmp-exif:gpslatituderef#}' \
  *.xmp

[...]

After that .xmp looks like this and the standard "DDD,MM.mmk" is used. Is it possible or needed to get rid of those references as separate tags?

I would suggest doing this to clean up the incorrect XMP-exif (there are other problems too):

exiftool -xmp-exif:all= -tagsfromfile @ -xmp-exif:all \
  '-xmp-exif:gpslongitude<${xmp-exif:gpslongitude#}${xmp-exif:gpslongituderef#}' \
  '-xmp-exif:gpslatitude<${xmp-exif:gpslatitude#}${xmp-exif:gpslatituderef#}' \
  *.xmp

- 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: Phil Harvey on June 27, 2023, 07:04:42 AMI would suggest doing this to clean up the incorrect XMP-exif

Thanks, that works.

- Matti