Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPSLatitude and GPSLongitude differs from GPSPosition #165

Closed
waclaw66 opened this issue Dec 29, 2023 · 6 comments
Closed

GPSLatitude and GPSLongitude differs from GPSPosition #165

waclaw66 opened this issue Dec 29, 2023 · 6 comments

Comments

@waclaw66
Copy link

waclaw66 commented Dec 29, 2023

Describe the bug
Tags GPSLatitude and GPSLongitude don't match GPSPosition extracted using exiftool-vendored 24.2.0 from the picture below

  GPSLatitude: 37.6186111111111,
  GPSLongitude: 112.160555555556,
  GPSPosition: '37.6186111111111 -112.160555555556',

exiftool 12.70 shows...
$exiftool -c "%+f" -EXIF:GPS -GPSLatitude -GPSLongitude -GPSPosition

GPS Latitude                    : +37.618611
GPS Longitude                   : -112.160556
GPS Position                    : +37.618611, -112.160556

20140530_125154_HDR

To Reproduce
Just use the example snippet for reading tags.

Expected behavior
GPSLongitude should be -112.160555555556

Environment (please complete the following information):

  • Fedora 39
  • Node.JS v20.10.0
@mceachen
Copy link
Member

mceachen commented Dec 31, 2023

That is a fantastic shot of Bryce!

Thanks for taking the time to report this.

First off, here's this library's code for extracting latitude and longitude:

#extractLatLon = lazy(() => {

You'll see I look at the "GPSLongitudeRef" value to know when the value needs to be negated. If the ref is West, I force it to negative, and if it's East, I force it to a positive value. Some prior versions of ExifTool returned absolute values of lat/lon, which required this code.

Your file has a negative longitude with an East ref, which I believe is invalid. I just checked my image repository of examples, and there isn't a single case where a negative GPS Longitude has a GPS Longitude Ref of "East".

Given that recent versions of ExifTool have been giving the proper signed values for GPS lat/lon, I think it's reasonable to remove the Math.abs() call here.

I'll append a warning message to the warnings array in the case that Ref seems to not match up with the sign of the lat or lon.

@waclaw66
Copy link
Author

waclaw66 commented Jan 1, 2024

Perfect, thanks for a quick fix!

@waclaw66
Copy link
Author

waclaw66 commented Jan 23, 2024

Seems it affects xmp sidecar files as well. immich-app/immich#6580

<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:photoshop="http://ns.adobe.com/photoshop/1.0/">
         <exif:GPSLongitude>81.574116666666669</exif:GPSLongitude>
         <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
         <exif:GPSHPositioningError>0.0</exif:GPSHPositioningError>
         <exif:GPSSpeedRef>K</exif:GPSSpeedRef>
         <exif:GPSLatitudeRef>N</exif:GPSLatitudeRef>
         <exif:GPSLatitude>28.416161666666667</exif:GPSLatitude>
         <exif:GPSImgDirectionRef>T</exif:GPSImgDirectionRef>
         <exif:GPSTimeStamp>2001-01-01T00:00:00Z</exif:GPSTimeStamp>
         <exif:GPSSpeed>0.0</exif:GPSSpeed>
         <exif:GPSImgDirection>0.0</exif:GPSImgDirection>
         <photoshop:DateCreated>2016-01-23T10:36:32-05:00</photoshop:DateCreated>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>
  SourceFile: '/mnt/data/pub/immich-library/immich-xmp-test-0.jpg.xmp',
  tz: 'Asia/Kathmandu',
  tzSource: 'GPSLatitude/GPSLongitude',
  GPSLatitude: 28.4161616666667,
  GPSLongitude: 81.5741166666667,
  GPSPosition: '28.4161616666667 81.5741166666667',
  GPSLatitudeRef: 'North',
  GPSLongitudeRef: 'East',
  ExifToolVersion: 12.72,

GPSLongitudeRef is not parsed correctly.

@mceachen
Copy link
Member

mceachen commented Jan 23, 2024

This new issue is related, but is a different situation and behavior from the original issue. In the future please open a new issue (feel free to reference related issues, of course!)

This library is passing through the value it's getting from ExifTool. I'm seeing "East" as the GPSLongitudeRef, so there's nothing I can do from my side--I don't have access to the "raw" values, so I can't (and feel like I really shouldn't) add an additional "workaround" like the first issue.

There are several handfuls of bug reports in the ExifTool forum around this issue, along with remediations:

https://exiftool.org/forum/index.php?topic=10163.msg52950#msg52950

https://exiftool.org/forum/index.php?topic=14943.msg80546#msg80546

@waclaw66
Copy link
Author

This library is passing through the value it's getting from ExifTool. I'm seeing "East" as the GPSLongitudeRef

I'm sorry, I haven't realized that "East" value comes from exiftool itself. Will check it first with exiftool next time. Thanks.

@mceachen
Copy link
Member

No worries--I appreciate the time you took to gather a simple reproduction for me.

(And if you discover there's some more proper heuristic I should apply, or exiftool magick arg I should use, I'm all ears!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants