XMP2GPS.args and XMP-iptcExt LocationShown Lat/Lon

Started by Mac2, July 09, 2019, 09:42:37 AM

Previous topic - Next topic

Mac2

I've recently encountered a issue when mapping XMP GPS data back to native GPS using the GPS2XMP.args file that puzzles me.

My application works like this:

+ Modify the XMP-exif Lat/Lon and Dest Lat/Lon as needed.
+ Write the XMP data to the target image with ExifTool
+ If the target image has native GPS data, run XMP2GPS.args to synchronize XMP->GPS

This works great.
But yesterday I've got a report where this was failing for a specific file (1.3 GB TIF, too large to attach, unfortunately).

The user tried to negate the longitude (because it was wrong in the file) but it always 'snapped back' after writing and re-reading the data.

After digging into the file I noticed two potential reasons for this:

The file has (wrong) data in the tags

[XMP-iptcExt]   Location Shown GPS Latitude
[XMP-iptcExt]   Location Shown GPS Longitude


as well as in

[XMP-drone-dji] GPS Latitude
[XMP-drone-dji] GPS Longitude


My software only updates the coordinates in XMP-exif.

I doubt that the dji data is of any importance for ExifTool but maybe the XMP-iptcExt data is somehow preferred over XMP-exif when mapping from XMP back into native GPS using the args file?

Phil Harvey

If you look at xmp2gps.args, you will see that it draws tags only from the XMP-exif namespace, except for the reference directions which come from the Composite tags (which are based only on XMP, so any namespace could be used).

The XMP-iptcExt LocationShownXxx tags should not be part of this equation because they have a different name (as well as being in a different namespace).

I don't really understand the problem.  Is it just that the reference directions are wrong?  If so, then I understand how this could happen.

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

Mac2

This was also puzzling for me.

The user wanted to correct the wrong longitude (recorded as 4.xx in the file) by negating it (-4.xx).
The original file has these tags:

[XMP-iptcExt]   Location Shown GPS Longitude    : 4.360133
[XMP-drone-dji] GPS Longitude                   : 4.360133
[XMP-exif]      GPS Longitude                   : 4.360133
[GPS]           GPS Longitude Ref               : E
[GPS]           GPS Longitude                   : 4.360133
[Composite]     GPS Longitude                   : 4.360133
[Composite]     GPS Longitude Ref               : E


When I change the 4.36 to -4.36 in my software, it updates and writes the XMP-exif Longitude, then runs XMP2GPS.args I end up with:

iptcExt]   Location Shown GPS Longitude    : 4.360133
[XMP-drone-dji] GPS Longitude                   : 4.360133
[XMP-exif]      GPS Longitude                   : -4.360133
[GPS]           GPS Longitude Ref               : E
[GPS]           GPS Longitude                   : 4.360133
[Composite]     GPS Longitude                   : 4.360133
[Composite]     GPS Longitude Ref               : E


I stripped the commands down a bit:


-overwrite_original_in_place
-charset
FILENAME=UTF8
-m
-use
MWG
-charset
ExifTool=UTF8
-ex
-tagsfromfile
FILE_NAME.TIF
-@
v:\exiftool\arg_files\exif2xmp.args
--Exif:rating
-@
v:\exiftool\arg_files\iptc2xmp.args
-@
v:\exiftool\arg_files\gps2xmp.args

-XMP-exif:GPSLongitude#=-4.360133

FILE_NAME.TIF
-execute

-overwrite_original_in_place
-charset
FILENAME=UTF8
-m
-GPS:all=
-tagsfromfile
FILE_NAME.TIF
-@
v:\exiftool\arg_files\xmp2exif.args
-@
v:\exiftool\arg_files\xmp2iptc.args
-@
v:\exiftool\arg_files\xmp2gps.args

FILE_NAME.TIF


My software deals with a wide range of files from the past 20 years, and with a lot of metadata mess.
And usually the mapping from XMP to GPS just works.

When I delete both the native GPS data and the XMP data in the file before writing back the modified XMP data, I instead get


[XMP-exif]      GPS Longitude                   : -4.360133
[GPS]           GPS Longitude Ref               : W
[GPS]           GPS Longitude                   : 4.360133
[Composite]     GPS Longitude                   : -4.360133
[Composite]     GPS Longitude Ref               : W


which is correct in both GPS and Composite.

Hence my guess is that somehow the existing XMP/GPS data in the file interferes in this case.
Or I'm not thinking correct. Can happen.

Sorry for the long post but I wanted to give details.

Phil Harvey

Sorry for the delay in responding.  I wasn't able to look into this at the time, and forgot to get back to this when I had a chance.

I haven't been able to reproduce the effect you are seeing.  This is what I get with ExifTool 11.60:

> exiftool "-*gpslongitude*" -G1 -a a.jpg
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 4.000000
[XMP-iptcExt]   Location Shown GPS Longitude    : 4.000000 E
[XMP-drone-dji] GPS Longitude                   : 4.000000 E
[XMP-exif]      GPS Longitude                   : 4.000000 E
[Composite]     GPS Longitude                   : 4.000000 E
[Composite]     GPS Longitude Ref               : East
> exiftool -use mwg -@ arg_files/exif2xmp.args -@ arg_files/gps2xmp.args -xmp-exif:gpslongitude#=-4 a.jpg
    1 image files updated
> exiftool "-*gpslongitude*" -G1 -a a.jpg
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 4.000000
[XMP-iptcExt]   Location Shown GPS Longitude    : 4.000000 E
[XMP-drone-dji] GPS Longitude                   : 4.000000 E
[XMP-exif]      GPS Longitude                   : 4.000000 W
[Composite]     GPS Longitude                   : 4.000000 E
[Composite]     GPS Longitude Ref               : West
> exiftool -@ arg_files/xmp2exif.args -@ arg_files/xmp2iptc.args -@ arg_files/xmp2gps.args a.jpg
    1 image files updated
> exiftool "-*gpslongitude*" -G1 -a a.jpg
[GPS]           GPS Longitude Ref               : West
[GPS]           GPS Longitude                   : 4.000000
[XMP-iptcExt]   Location Shown GPS Longitude    : 4.000000 E
[XMP-drone-dji] GPS Longitude                   : 4.000000 E
[XMP-exif]      GPS Longitude                   : 4.000000 W
[Composite]     GPS Longitude                   : 4.000000 W
[Composite]     GPS Longitude Ref               : West


... but I suspect the problem depends on the actual order of the metadata in the file.  Composite:GPSLongitudeRef is derived from XMP:GPSLonitude, and whether it takes the XMP-exif or XMP-drone-dji version depends on the order in the file.  To fix this I should maybe change the Composite tag to use XMP-exif specifically.  I'll think about making this change in version 11.61.

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

Mac2

Hi, Phil

thanks for taking the time to look at this. I'd already forgotten about this support ticket. I get so many every day, and many of them are from the 'my metadata is in a mess' category.
Since we've found a fix (clean the file and let ET write it fresh) I marked it as closed in my system and moved on  ;)

I can only offer you to send you the file (or rather upload it somewhere, because its a well over 1 GB TIFF file). If it would be helpful for you to see the original data.

Phil Harvey

Could you try 11.61 (just released) to see if this solves the problem?

Thanks.

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

Mac2

Yes, I will do that. I'll migrate a database to the latest ExifTool and run some tests on the image. I'll post what I find out.

Mac2

I've did a test with the 11.61 release for this file.

The file starts with
[XMP-iptcExt]   Location Shown GPS Latitude     : 51.738652
[XMP-iptcExt]   Location Shown GPS Longitude    : 4.360133
[XMP-drone-dji] GPS Latitude                    : 51.738652
[XMP-drone-dji] GPS Longitude                   : 4.360133
[XMP-exif]      GPS Altitude                    : 9.93
[XMP-exif]      GPS Latitude                    : 51.738652
[XMP-exif]      GPS Longitude                   : 4.360133
[XMP-exif]      GPS Version ID                  : 2.3.0.0
[GPS]           GPS Version ID                  : 2 3 0 0
[GPS]           GPS Latitude Ref                : N
[GPS]           GPS Latitude                    : 51.738652
[GPS]           GPS Longitude Ref               : E
[GPS]           GPS Longitude                   : 4.360133
[GPS]           GPS Altitude                    : 9.93
[Composite]     GPS Latitude                    : 51.738652
[Composite]     GPS Longitude                   : 4.360133
[Composite]     GPS Latitude Ref                : N
[Composite]     GPS Longitude Ref               : E
[Composite]     GPS Position                    : 51.738652 4.360133


I negate the longitude in my software and let ExifTool write back the change with the following args file (edited for brevity)

-use
MWG
-ex
-tagsfromfile
c:\test.tif
-@
v:\exiftool\arg_files\exif2xmp.args
--Exif:rating
-@
v:\exiftool\arg_files\iptc2xmp.args
-@
v:\exiftool\arg_files\gps2xmp.args

-XMP-exif:GPSLongitude#=-4.360133
c:\test.tif
-execute

-m
-EXIF:ImageDescription=
-EXIF:Software=
...
-IPTC:DigitalCreationDate=
-IPTC:DigitalCreationTime=

-GPS:all=

-tagsfromfile
c:\test.tif
-@
v:\exiftool\arg_files\xmp2exif.args
-@
v:\exiftool\arg_files\xmp2iptc.args
-@
v:\exiftool\arg_files\xmp2gps.args

c:\test.tif
-execute9999


and this still produces the unexpected result:


[XMP-iptcExt]   Location Shown GPS Latitude     : 51.738652
[XMP-iptcExt]   Location Shown GPS Longitude    : 4.360133
[XMP-drone-dji] GPS Latitude                    : 51.738652
[XMP-drone-dji] GPS Longitude                   : 4.360133
[XMP-exif]      GPS Altitude                    : 9.93
[XMP-exif]      GPS Latitude                    : 51.738652
[XMP-exif]      GPS Longitude                   : -4.360133
[XMP-exif]      GPS Version ID                  : 2.3.0.0
[GPS]           GPS Version ID                  : 2 3 0 0
[GPS]           GPS Latitude Ref                : N
[GPS]           GPS Latitude                    : 51.738652
[GPS]           GPS Longitude Ref               : W
[GPS]           GPS Longitude                   : 4.360133
[GPS]           GPS Altitude                    : 9.93
[Composite]     GPS Latitude                    : 51.738652
[Composite]     GPS Longitude                   : -4.360133
[Composite]     GPS Latitude Ref                : N
[Composite]     GPS Longitude Ref               : W
[Composite]     GPS Position                    : 51.738652 -4.360133


I would have expected that the native GPS longitude is also -4.36...

Phil Harvey

This is the correct result.  The EXIF GPSLongitude is unsigned according to the specification.

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

Mac2

Of course! Stupid me.
The GPS longitude ref has changed to E to W. This wasn't the case with the older ExifTool version. So the problem seems to be fixed?

Phil Harvey

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