12.36-12.38: Importing GPS tags from Apple Photos XMP truncates coordinates

Started by cjbob, January 05, 2022, 04:49:19 PM

Previous topic - Next topic

cjbob

Hello, first-time poster. I think I have found a bug in ExifTool versions 12.36 through 12.38 concerning writing GPS coordinates to an image from an XMP sidecar file.

I have some JPG and XMP files originally exported from Apple Photos circa 2019. Some of these XMP files contain GPS metadata.

I bulk-updated images in a folder using this command line:

exiftool.exe -tagsfromfile "%d%f.XMP" -all:all -ext jpg -ext JPG -ext jpeg -ext JPEG -r {DIR}

Using ExifTool 12.13 at the time, this resulted in the GPS metadata being shuffled around a little, but the GPS coordinates were correct after the write.

Using ExifTool 12.36, 12.37 and 12.38 (the latest at time of writing), the same command line run against a folder with a single JPG/XMP file pair results in:

Command Output:
1 directories scanned
1 image files updated


Inspecting the metadata with ExifTool (truncated results, actual GPS coordinates obfuscated):

Before (source file):
[ExifTool]      ExifToolVersion                 : 12.30
[EXIF]          GPSLatitudeRef                  : South
[EXIF]          GPSLongitudeRef                 : East
[EXIF]          GPSAltitudeRef                  : Above Sea Level
[EXIF]          GPSTimeStamp                    : 21:34:45.86
[Composite]     GPSAltitude                     : 21 m Above Sea Level
[Composite]     GPSLatitude                     : 38 deg 19' 55.20" S
[Composite]     GPSLongitude                    : 176 deg 9' 28.80" E
[Composite]     GPSPosition                     : 38 deg 19' 55.20" S, 176 deg 9' 28.80" E


After:
[ExifTool]      ExifToolVersion                 : 12.30
[EXIF]          GPSAltitudeRef                  : Above Sea Level
[EXIF]          GPSTimeStamp                    : 21:34:45.86
[XMP]           XMPToolkit                      : Image::ExifTool 12.38
[Composite]     GPSAltitude                     : 21 m Above Sea Level
[Composite]     GPSLatitude                     : 38 deg 0' 0.00" S
[Composite]     GPSLongitude                    : 176 deg 0' 0.00" E
[Composite]     GPSLatitudeRef                  : South
[Composite]     GPSLongitudeRef                 : East
[Composite]     GPSPosition                     : 38 deg 0' 0.00" S, 176 deg 0' 0.00" E


i.e. the GPS coordinates have been truncated to just their degree values.

The XMP file has its GPS coordinates formatted as below:
<?xpacket begin='' id=''?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9-9, framework 1.6'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'>
<rdf:Description rdf:about='' xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
</rdf:Description>
<rdf:Description rdf:about='' xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>
</rdf:Description>
<rdf:Description rdf:about='' xmlns:dc='http://purl.org/dc/elements/1.1/'>
</rdf:Description>
<rdf:Description rdf:about='' xmlns:photomechanic='http://ns.camerabits.com/photomechanic/1.0/'>
</rdf:Description>
<rdf:Description rdf:about='' xmlns:exif='http://ns.adobe.com/exif/1.0/'>
<exif:GPSLatitude>38,19.92000000S</exif:GPSLatitude>
<exif:GPSLongitude>176,9.48000000E</exif:GPSLongitude>
<exif:GPSAltitude>21000/1000</exif:GPSAltitude>
<exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>


(I am wondering whether the comma in the GPS coordinates is confusing these later versions of ExifTool...)

I have seen this truncation occur in versions 12.36, 12.37 and 12.38. The truncation does not occur in versions 12.13, 12.30, and 12.35 (not an exhaustive list).

Environment:
Windows 10 Enterprise 21H2 x64

Phil Harvey

I don't understand what you are doing.

You are copying tags from an XMP file to the same location in a JPG file (ie. written as XMP, not EXIF).  But are you are showing EXIF tags in your before/after output.  Could you show the output of the following command before and after?:

exiftool -a -G1 "-gps*" FILE

And note that the -ext option is not case sensitive, so you don't need to repeat it for the other case.

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

cjbob

Hi, Phil -

Long story short: I'm not specifically trying to update GPS metadata from an XMP to a JPG where the data already exists (why would you? :) ) This situation is a bit of an edge case of the process I used to extricate ourselves from Apple Photos.

The best (only?) way I could find to preserve the people tagging I'd done in Apple Photos was to get it to export photos with a corresponding XMP sidecar. (I lost the face regions, but could live with that.)

The XMP sidecars contained various combinations of:

  • Person tagging (which was never found embedded in the corresponding image file)
  • GPS data (which was often embedded in the corresponding image file, but not always)

So, back then, I used ExifTool (versions 12.10 to 12.13 I believe) to write all the data in the sidecar to the image file, using the supplied command line. I checked the situation where there was GPS data in the image file prior, and it was present after (albeit somewhat rearranged). All good.

I recently found more photos from that Apple Photos export process, and did the same process but using exiftool 12.38. It was then that I found that the GPS data was being truncated.

I perhaps could have been more specific with my ExifTool commands, only writing GPS data in the XMP if it was not present in the JPG, but didn't see the harm as it seemed to work flawlessly previously.

As requested, here is the result of your exiftool command run against another JPG/XMP file pair.

Before (source file):

[GPS]           GPS Latitude Ref                : South
[GPS]           GPS Latitude                    : 36 deg 52' 51.57"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 174 deg 37' 57.03"
[GPS]           GPS Altitude Ref                : Above Sea Level
[GPS]           GPS Altitude                    : 22 m
[GPS]           GPS Time Stamp                  : 01:52:57.22
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 131.1513761
[Composite]     GPS Altitude                    : 22 m Above Sea Level
[Composite]     GPS Latitude                    : 36 deg 52' 51.57" S
[Composite]     GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Position                    : 36 deg 52' 51.57" S, 174 deg 37' 57.03" E


After (written by ExifTool 12.30):

[GPS]           GPS Latitude Ref                : South
[GPS]           GPS Latitude                    : 36 deg 52' 51.57"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 174 deg 37' 57.03"
[GPS]           GPS Altitude Ref                : Above Sea Level
[GPS]           GPS Altitude                    : 22 m
[GPS]           GPS Time Stamp                  : 01:52:57.22
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 131.1513761
[XMP-exif]      GPS Altitude                    : 22 m
[XMP-exif]      GPS Altitude Ref                : Above Sea Level
[XMP-exif]      GPS Img Direction               : 131.151376146789
[XMP-exif]      GPS Img Direction Ref           : True North
[XMP-exif]      GPS Latitude                    : 36 deg 52' 51.57" S
[XMP-exif]      GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Altitude                    : 22 m Above Sea Level
[Composite]     GPS Latitude                    : 36 deg 52' 51.57" S
[Composite]     GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Latitude Ref                : South
[Composite]     GPS Longitude Ref               : East
[Composite]     GPS Position                    : 36 deg 52' 51.57" S, 174 deg 37' 57.03" E


After (written by ExifTool 12.38):

[GPS]           GPS Latitude Ref                : South
[GPS]           GPS Latitude                    : 36 deg 0' 0.00"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 174 deg 0' 0.00"
[GPS]           GPS Altitude Ref                : Above Sea Level
[GPS]           GPS Altitude                    : 22 m
[GPS]           GPS Time Stamp                  : 01:52:57.22
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 131.1513761
[XMP-exif]      GPS Altitude                    : 22 m
[XMP-exif]      GPS Altitude Ref                : Above Sea Level
[XMP-exif]      GPS Img Direction               : 131.151376146789
[XMP-exif]      GPS Img Direction Ref           : True North
[XMP-exif]      GPS Latitude                    : 36 deg 52' 51.57" S
[XMP-exif]      GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Altitude                    : 22 m Above Sea Level
[Composite]     GPS Latitude                    : 36 deg 0' 0.00" S
[Composite]     GPS Longitude                   : 174 deg 0' 0.00" E
[Composite]     GPS Latitude Ref                : South
[Composite]     GPS Longitude Ref               : East
[Composite]     GPS Position                    : 36 deg 0' 0.00" S, 174 deg 0' 0.00" E


P.S. thank you for the clarification regarding the '-ext' switch case insensitivity.

Phil Harvey

I'm sorry, I still don't understand.

I assume this is the command you are using:

exiftool.exe -tagsfromfile "%d%f.XMP" -all:all -ext jpg -ext JPG -ext jpeg -ext JPEG -r {DIR}

with the posted XMP file.

Then when you say "source file", you mean the JPG file before the command?   And "After" means the same file after you copied tags from the XMP file according to the command above?  If so, then tags in the GPS group should not be changed.  Only XMP tags will be written.  So either I'm not understanding, or your are doing something else with your command, or there is something funny with the file(s) you are using.

Can you post the exact command you are using, plus the sample files so I can reproduce this myself?

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

cjbob

QuoteThen when you say "source file", you mean the JPG file before the command?

Yes.

QuoteAnd "After" means the same file after you copied tags from the XMP file according to the command above?

Yes, the JPG in both instances.

QuoteIf so, then tags in the GPS group should not be changed.

I agree :) They are not changed when using ExifTool 12.30, but they are when using ExifTool 12.38.

Here is the command I'm using (very similar to the one you mentioned, just with the duplicated ext switch removed):

exiftool.exe -tagsfromfile "%d%f.XMP" -all:all -ext jpg -ext jpeg -r {DIR}

...and I will send you a sample JPG/XMP file via email.

Thanks for looking into this.

Phil Harvey

OK.  Although I can't reproduce this problem (see below), I think I know why non-XMP tags are being written.  It is because I made the Composite GPSPosition tag writable as of version 12.36.  This made it a lot easier for me to geotag images from coordinates I got via Google Maps.  To avoid generating the Composite tags, add -e to your command.

However, I would still like to be able to reproduce this so I can see why the minutes/seconds are being lost.  Below is my command transcript for the files you sent:

> exiftool -config "" IMG_2652.JPG -a -G1 "-gps*"
[GPS]           GPS Latitude Ref                : South
[GPS]           GPS Latitude                    : 36 deg 52' 51.57"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 174 deg 37' 57.03"
[GPS]           GPS Altitude Ref                : Above Sea Level
[GPS]           GPS Altitude                    : 22 m
[GPS]           GPS Time Stamp                  : 01:52:57.22
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 131.1513761
[Composite]     GPS Altitude                    : 22 m Above Sea Level
[Composite]     GPS Latitude                    : 36 deg 52' 51.57" S
[Composite]     GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Position                    : 36 deg 52' 51.57" S, 174 deg 37' 57.03" E
> exiftool -config "" IMG_2652.JPG -tagsfromfile IMG_2652.XMP -all:all
    1 image files updated
> exiftool -config "" IMG_2652.JPG -a -G1 "-gps*"
[GPS]           GPS Latitude Ref                : South
[GPS]           GPS Latitude                    : 36 deg 52' 51.57"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 174 deg 37' 57.03"
[GPS]           GPS Altitude Ref                : Above Sea Level
[GPS]           GPS Altitude                    : 22 m
[GPS]           GPS Time Stamp                  : 01:52:57.22
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 131.1513761
[XMP-exif]      GPS Altitude                    : 22 m
[XMP-exif]      GPS Altitude Ref                : Above Sea Level
[XMP-exif]      GPS Img Direction               : 131.151376146789
[XMP-exif]      GPS Img Direction Ref           : True North
[XMP-exif]      GPS Latitude                    : 36 deg 52' 51.57" S
[XMP-exif]      GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Altitude                    : 22 m Above Sea Level
[Composite]     GPS Latitude                    : 36 deg 52' 51.57" S
[Composite]     GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Latitude Ref                : South
[Composite]     GPS Longitude Ref               : East
[Composite]     GPS Position                    : 36 deg 52' 51.57" S, 174 deg 37' 57.03" E


You get different results when you do exactly as I did above?  If not, what are you doing differently to get the zero minutes/seconds?  Note that I have disabled the config file with -config "" in case you have a config file which is causing a difference.

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

cjbob

Thanks, Phil.

Here is what I've tried:


  • Restart computer again!
  • Use an edited XMP with no subject duplication (remove duplicated lines)
  • Use an edited XMP with no subject duplication and no HTML formatting (e.g. "&apos;")
  • Try on a different computer (Windows 10 Enterprise 1909 x64), which has never had ExifTool on it
  • ExifTool executable, JPG and XMP all in same folder, run from there
  • Keyboard changed to English (US) (was: Maori), restart
  • Regional Formatting changed to English (United States) (was: English (New Zealand)), restart

All of the above gives me the same truncated-coordinate output:

C:\temp\PH_GPS>exiftool -ver
12.38

C:\temp\PH_GPS>exiftool -config "" IMG_2652.JPG -a -G1 "-gps*"
[GPS]           GPS Latitude Ref                : South
[GPS]           GPS Latitude                    : 36 deg 52' 51.57"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 174 deg 37' 57.03"
[GPS]           GPS Altitude Ref                : Above Sea Level
[GPS]           GPS Altitude                    : 22 m
[GPS]           GPS Time Stamp                  : 01:52:57.22
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 131.1513761
[Composite]     GPS Altitude                    : 22 m Above Sea Level
[Composite]     GPS Latitude                    : 36 deg 52' 51.57" S
[Composite]     GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Position                    : 36 deg 52' 51.57" S, 174 deg 37' 57.03" E

C:\temp\PH_GPS>exiftool -config "" IMG_2652.JPG -tagsfromfile IMG_2652.XMP -all:all
    1 image files updated

C:\temp\PH_GPS>exiftool -config "" IMG_2652.JPG -a -G1 "-gps*"
[GPS]           GPS Latitude Ref                : South
[GPS]           GPS Latitude                    : 36 deg 0' 0.00"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 174 deg 0' 0.00"
[GPS]           GPS Altitude Ref                : Above Sea Level
[GPS]           GPS Altitude                    : 22 m
[GPS]           GPS Time Stamp                  : 01:52:57.22
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 131.1513761
[XMP-exif]      GPS Altitude                    : 22 m
[XMP-exif]      GPS Altitude Ref                : Above Sea Level
[XMP-exif]      GPS Img Direction               : 131.151376146789
[XMP-exif]      GPS Img Direction Ref           : True North
[XMP-exif]      GPS Latitude                    : 36 deg 52' 51.57" S
[XMP-exif]      GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Altitude                    : 22 m Above Sea Level
[Composite]     GPS Latitude                    : 36 deg 0' 0.00" S
[Composite]     GPS Longitude                   : 174 deg 0' 0.00" E
[Composite]     GPS Latitude Ref                : South
[Composite]     GPS Longitude Ref               : East
[Composite]     GPS Position                    : 36 deg 0' 0.00" S, 174 deg 0' 0.00" E


The last thing I tried was to use Oliver Betz's builds (both x64 and x86). They work as expected, with no coordinate truncation:

C:\temp\PH_GPS>exiftool -ver
12.38

C:\temp\PH_GPS>exiftool -config "" IMG_2652.JPG -a -G1 "-gps*"
[GPS]           GPS Latitude Ref                : South
[GPS]           GPS Latitude                    : 36 deg 52' 51.57"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 174 deg 37' 57.03"
[GPS]           GPS Altitude Ref                : Above Sea Level
[GPS]           GPS Altitude                    : 22 m
[GPS]           GPS Time Stamp                  : 01:52:57.22
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 131.1513761
[Composite]     GPS Altitude                    : 22 m Above Sea Level
[Composite]     GPS Latitude                    : 36 deg 52' 51.57" S
[Composite]     GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Position                    : 36 deg 52' 51.57" S, 174 deg 37' 57.03" E

C:\temp\PH_GPS>exiftool -config "" IMG_2652.JPG -tagsfromfile IMG_2652.XMP -all:all
    1 image files updated

C:\temp\PH_GPS>exiftool -config "" IMG_2652.JPG -a -G1 "-gps*"
[GPS]           GPS Latitude Ref                : South
[GPS]           GPS Latitude                    : 36 deg 52' 51.57"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 174 deg 37' 57.03"
[GPS]           GPS Altitude Ref                : Above Sea Level
[GPS]           GPS Altitude                    : 22 m
[GPS]           GPS Time Stamp                  : 01:52:57.22
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 131.1513761
[XMP-exif]      GPS Altitude                    : 22 m
[XMP-exif]      GPS Altitude Ref                : Above Sea Level
[XMP-exif]      GPS Img Direction               : 131.151376146789
[XMP-exif]      GPS Img Direction Ref           : True North
[XMP-exif]      GPS Latitude                    : 36 deg 52' 51.57" S
[XMP-exif]      GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Altitude                    : 22 m Above Sea Level
[Composite]     GPS Latitude                    : 36 deg 52' 51.57" S
[Composite]     GPS Longitude                   : 174 deg 37' 57.03" E
[Composite]     GPS Latitude Ref                : South
[Composite]     GPS Longitude Ref               : East
[Composite]     GPS Position                    : 36 deg 52' 51.57" S, 174 deg 37' 57.03" E


So that's weird and interesting...

Were your tests run on Windows? If not, could that be the reason for the different result - something OS-related?

Phil Harvey

Well, that is a puzzle.  Thanks for running your tests.  O/S differences are very rare, but I'll look into this.  It may take me a few days but I'll post back here after I've run some more tests.

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

Phil Harvey

This was bugging me so I made room for a few hours today to work on this.

Wow, what a fun puzzle.

The result you are getting was difficult to reproduce, but I finally managed to do it.  There were 3 or 4 very subtle things going on here, and changing any of these makes the problem go away. The main problem was that I should have added a conversion from DMS format when I added the ability to write GPSPosition in version 12.36.  ExifTool 12.39 will fix this.  As well, I will make GPSPosition protected so it isn't written by default, which will doubly patch this problem.

Thanks for bringing this to my attention, and helping me to find this very elusive bug.

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

cjbob