My app let users adjust GPS position by clicking on a map. Exiftool is used to update the metadata. Recent versions (11.41 and 11.42, probably others) is not handling GPSLongitudeRef correctly. In this example I'm updating an XMP file, but the issue happens on other files types, too.
This command command line example shows the problem. The arguments are those generated by my app.
exiftool IMG_3892.xmp > before
exiftool -q -m -overwrite_original_in_place -GPSLatitude=37.515030555555555 -GPSLatitudeRef=N -GPSLongitude=122.33951666666667 -GPSLongitudeRef=W -GPSDateStamp="2019:05:26 12:25:27 -07:00" -GPSTimeStamp="2019:05:26 12:25:27 -07:00" -AllDates="2019:05:26 12:25:27" -GPSStatus= IMG_3892.xmp
exiftool IMG_3892.xmp > after
Note that I set -GPSLongitudeRef=W. The results:
exiftool IMG_3892.xmp | grep GPS
GPS Altitude Ref : Above Sea Level
GPS Dest Bearing : 334.076049943246
GPS Dest Bearing Ref : Magnetic North
GPS Horizontal Positioning Error: 20.44752901759 m
GPS Img Direction : 334.076049943246
GPS Img Direction Ref : Magnetic North
GPS Latitude : 37 deg 30' 54.11" N
GPS Longitude : 122 deg 20' 22.26" E
GPS Speed : 0.215028092408767
GPS Speed Ref : km/h
GPS Date/Time : 2019:05:26 19:25:24.86Z
GPS Altitude : 156.6 m Above Sea Level
GPS Latitude Ref : North
GPS Longitude Ref : East
GPS Position : 37 deg 30' 54.11" N, 122 deg 20' 22.26" E
The GPSLongitudeRef is still East.
The before and after diffs:
diff -u before after
--- before 2019-05-28 12:36:48.000000000 -0700
+++ after 2019-05-28 12:43:16.000000000 -0700
@@ -2,14 +2,14 @@
File Name : IMG_3892.xmp
Directory : .
File Size : 4.9 kB
-File Modification Date/Time : 2019:05:28 12:28:41-07:00
-File Access Date/Time : 2019:05:28 12:36:48-07:00
-File Inode Change Date/Time : 2019:05:28 12:28:41-07:00
+File Modification Date/Time : 2019:05:28 12:42:58-07:00
+File Access Date/Time : 2019:05:28 12:43:00-07:00
+File Inode Change Date/Time : 2019:05:28 12:42:58-07:00
File Permissions : rw-r--r--
File Type : XMP
File Type Extension : xmp
MIME Type : application/rdf+xml
-XMP Toolkit : Image::ExifTool 11.44
+XMP Toolkit : Image::ExifTool 11.41
Lens : iPhone XS back dual camera 4.25mm f/1.8
Lens Info : 4.25-6mm f/1.8-2.4
Raw File Name : IMG_3892.HEIC
The XMP Tookit version difference is because I haven't yet updated the version I run from the command line. I'm running on macOS 10.14.5. I saw the same issue when using a negative longitude to indicate a W reference.
Any suggestions?
XMP doesn't store a separate reference direction. You should add N/S/E/W to the lat/lon value, or make it signed when writing XMP. Add -G1 when extracting tags to avoid confusion. The reference direction tags you are seeing are Composite tags.
- Phil
Thank you. I'll give that a try. I was pretty sure I was doing something wrong.
Edit: Yup. That fixed it. Thank you again.
Instead of using grep, you can use a wildcard in the tag name. Try
exiftool -gps* -G1 IMG_3892.xmp
The full gps output creating an xmp using your command
C:\>exiftool -q -m -overwrite_original_in_place -GPSLatitude=37.515030555555555 -GPSLatitudeRef=N -GPSLongitude=122.33951666666667 -GPSLongitudeRef=W -GPSDateStamp="2019:05:26 12:25:27 -07:00" -GPSTimeStamp="2019:05:26 12:25:27 -07:00" -AllDates="2019:05:26 12:25:27" y:\!temp\Test4.xmp
C:\>exiftool -G1 -a -s -gps* y:\!temp\Test4.xmp
[XMP-exif] GPSLatitude : 37 deg 30' 54.11" N
[XMP-exif] GPSLongitude : 122 deg 20' 22.26" E
[Composite] GPSLatitudeRef : North
[Composite] GPSLongitudeRef : East
[Composite] GPSPosition : 37 deg 30' 54.11" N, 122 deg 20' 22.26" E
Take note that there is no gps time included. That is because in XMP, the tag is GPSDateTime (see note under GPSDateTime on the XMP tags page (https://exiftool.org/TagNames/XMP.html#exif)).
Your command should be more along these lines
C:\>exiftool -q -m -overwrite_original_in_place -GPSLatitude="37.515030555555555 N" -GPSLongitude="122.33951666666667 W" -GPSDateTime="2019:05:26 12:25:27 -07:00" -AllDates="2019:05:26 12:25:27" y:\!temp\Test4.xmp
C:\>exiftool -G1 -a -s -gps* y:\!temp\Test4.xmp
[XMP-exif] GPSLatitude : 37 deg 30' 54.11" N
[XMP-exif] GPSLongitude : 122 deg 20' 22.26" W
[XMP-exif] GPSDateTime : 2019:05:26 12:25:27-07:00
[Composite] GPSLatitudeRef : North
[Composite] GPSLongitudeRef : West
[Composite] GPSPosition : 37 deg 30' 54.11" N, 122 deg 20' 22.26" W
From your sig:
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.
That's what I thought I was doing!
Heh, you got me there. And it's absolutely true with regards to GPS coordinates in the EXIF block, which is the most common problem that pops up here. Problems with XMP GPS data is less common.
You can just pass the raw digital value including negative sign to all three tags and let exiftool figure out things. For example
-GPS:GPSLongitude=-122.33951666666667 -GPS:GPSLongitudeRef=-122.33951666666667 -XMP:GPSLongitude=-122.33951666666667
What I actually do is use an exiftool shortcut to write all three tags at once. For me, I would just write
-MyLong=-122.33951666666667
All I did was add this bit to the shortcut section of my .exiftool_config, though I'm not sure how well that would work in your case.
MyLong => ['GPS:GPSLongitude', 'GPS:GPSLongitudeRef', 'XMP:GPSLongitude'],
MyLat => ['GPS:GPSLatitude','GPS:GPSLatitudeRef','XMP:GPSLatitude'],
MyAlt => ['GPS:GPSAltitude', 'GPS:GPSAltitudeRef', 'XMP:GPSAltitude', 'XMP:GPSAltitudeRef'],
Don't ask me about video GPS, though, I haven't played with the new exiftool video ability yet.
Quote from: StarGeek on May 28, 2019, 05:40:01 PM
You can just pass the raw digital value including negative sign to all three tags and let exiftool figure out things. For example
-GPS:GPSLongitude=-122.33951666666667 -GPS:GPSLongitudeRef=-122.33951666666667 -XMP:GPSLongitude=-122.33951666666667
That is a good idea, but I would drop the "GPS:" and "XMP:" from all of the tags to let ExifTool decide where to put them:
-GPSLongitude=-122.33951666666667 -GPSLongitudeRef=-122.33951666666667- Phil
This
-GPSLongitude=-122.33951666666667 -GPSLongitudeRef=-122.33951666666667
seems to work for all files. My first fix worked for xmp files but not dng files.