After v12.50, negative GPS values are written as positive

Started by mceachen, February 12, 2023, 06:33:34 PM

Previous topic - Next topic

mceachen

v12.50 behaves as expected:

$ bin/exiftool -ver
12.50
$ bin/exiftool -GPSPosition="39.1,-84.7" test-v12.50.mie
    1 image files created
$ bin/exiftool -GPS\*# test-v12.50.mie
GPS Version ID                  : 2 3 0 0
GPS Latitude Ref                : N
GPS Longitude Ref               : W
GPS Latitude                    : 39.1
GPS Longitude                   : -84.7
GPS Position                    : 39.1 -84.7

Versions after 12.50, though, neither setting GPSPosition nor GPSLatitude and GPSLatitude separately seem to not work properly:

$ bin/exiftool -ver
12.54
$ bin/exiftool -GPSPosition="39.1,-84.7" test-v12.54.mie
    1 image files created
$ bin/exiftool -GPS\*# test-v12.54.mie
GPS Latitude                    : 39.1
GPS Longitude                   : 84.7
GPS Position                    : 39.1 84.7

ExifTool behaves the same on Windows and Linux, FWIW, so this isn't an OS thing.

Am I doing it wrong, or is this unexpected?

Thanks!

(I found this via a bug posted to exiftool-vendored: issue #131 )

StarGeek

This is probably from this change in version 12.51
QuoteFixed issue where GPS reference directions may be unknowingly written when using ExifTool 12.44 or later to write GPSLatitude or GPSLongitude without specifying a group name. The fix was to Avoid writing the Composite tags unless the Composite group is specified explicitly

As this reverts the behavor back to what version 12.42 does, and I assume 12.43 (don't have a copy of that)
PS C:\> exiftool_12.42 -GPSPosition="39.1,-84.7" test-v12.42.mie
    1 image files created
PS C:\> exiftool_12.50 -GPSPosition="39.1,-84.7" test-v12.50.mie
    1 image files created
PS C:\> exiftool_12.51 -GPSPosition="39.1,-84.7" test-v12.51.mie
    1 image files created
PS C:\> exiftool -G1 -a -s -gps* -n test-v12.??.mie
======== test-v12.42.mie
[MIE-GPS]      GPSLatitude                    : 39.1
[MIE-GPS]      GPSLongitude                    : 84.7
[Composite]    GPSPosition                    : 39.1 84.7
======== test-v12.50.mie
[GPS]          GPSVersionID                    : 2 3 0 0
[GPS]          GPSLatitudeRef                  : N
[GPS]          GPSLatitude                    : 39.1
[GPS]          GPSLongitudeRef                : W
[GPS]          GPSLongitude                    : 84.7
[MIE-GPS]      GPSLatitude                    : 39.1
[MIE-GPS]      GPSLongitude                    : 84.7
[Composite]    GPSLatitude                    : 39.1
[Composite]    GPSLongitude                    : -84.7
[Composite]    GPSPosition                    : 39.1 -84.7
======== test-v12.51.mie
[MIE-GPS]      GPSLatitude                    : 39.1
[MIE-GPS]      GPSLongitude                    : 84.7
[Composite]    GPSPosition                    : 39.1 84.7
    3 image files read
PS C:\>
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

#2
Thanks for pointing this out.  I get the same thing for MIE files, but EXIF and XMP work as expected.  I'll look into this and fix the MIE behaviour.

> exiftool a.mie a.xmp a.exif -gpsposition='-1,-2'
    3 image files created
> exiftool a.mie a.xmp a.exif "-gps*" -a -G1
======== a.mie
[MIE-GPS]       GPS Latitude                    : 1.000000 N
[MIE-GPS]       GPS Longitude                   : 2.000000 E
[Composite]     GPS Position                    : 1.000000 N, 2.000000 E
======== a.xmp
[XMP-exif]      GPS Latitude                    : 1.000000 S
[XMP-exif]      GPS Longitude                   : 2.000000 W
[Composite]     GPS Latitude Ref                : South
[Composite]     GPS Longitude Ref               : West
[Composite]     GPS Position                    : 1.000000 S, 2.000000 W
======== a.exif
[GPS]           GPS Version ID                  : 2.3.0.0
[GPS]           GPS Latitude Ref                : South
[GPS]           GPS Latitude                    : 1.000000
[GPS]           GPS Longitude Ref               : West
[GPS]           GPS Longitude                   : 2.000000
[Composite]     GPS Latitude                    : 1.000000 S
[Composite]     GPS Longitude                   : 2.000000 W
[Composite]     GPS Position                    : 1.000000 S, 2.000000 W
    3 image files read

However, the bug report you referenced isn't writing GPSPosition, so this is a different issue.  Writing GPSLatitude and GPSLongitude to EXIF requires that you also write the reference directions.  So you must either write them explicitly or use Composite:GPSLatitude/GPSLongitude to do this for you.  12.51 and later made these Composite tags unsafe because they could set the reference directions incorrectly if the user writes them before writing an unsigned coordinate.  So with regret I had to revert what I had hoped would be a useful change in 12.44 and stop automatically writing the reference directions.

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

mceachen

Apologies, but my first post I should have clarified that I tried using `-GPSLatitude` and `-GPSLongitude` separately and explicitly, as well as trying `GPSPosition`, and that neither had retained the signed numeric value.

Quote from: Phil Harvey on February 12, 2023, 09:28:35 PMWriting GPSLatitude and GPSLongitude to EXIF requires that you also write the reference directions.

Got it! I've added this to exiftool-vendored now: https://github.com/photostructure/exiftool-vendored.js/commit/174b25f35cb7844de8a51254713ff2d66f10a021

Thanks, you two!