[BUG] GPS Coordinates Are Not Correct If Coordinate Direction Is In Separate Field #1184

Closed
opened 2026-02-05 00:47:23 +03:00 by OVERLORD · 20 comments
Owner

Originally created by @thegranddesign on GitHub (Aug 4, 2023).

The bug

EXIF data has a specific field for the coordinate direction. When XMP file s contain this information, the coordinate is mapped incorrectly.

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.4.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:GPSSpeedRef>K</exif:GPSSpeedRef>
         <exif:GPSSpeed>0.0</exif:GPSSpeed>
         <exif:GPSTimeStamp>2009-01-01T00:00:00Z</exif:GPSTimeStamp>
         <exif:GPSImgDirection>291.76978416999998</exif:GPSImgDirection>
         <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
         <exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>
         <exif:GPSLongitude>68</exif:GPSLongitude>
         <exif:GPSLatitude>60.5</exif:GPSLatitude>
         <exif:GPSLatitudeRef>N</exif:GPSLatitudeRef>
         <exif:GPSImgDirectionRef>T</exif:GPSImgDirectionRef>
         <exif:GPSAltitude>121</exif:GPSAltitude>
         <exif:GPSHPositioningError>0.0</exif:GPSHPositioningError>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>

Immich currently displays this as in Russia because it doesn't take into account the Ref fields, however the correct location is Akpatok Island.

The OS that Immich Server is running on

N/A

Version of Immich Server

v1.69.0

Version of Immich Mobile App

N/A

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

N/A

Your .env content

N/A

Reproduction steps

1. Use the CLI to import a photo with a sidecar with the contents listed above.
...

Additional information

No response

Originally created by @thegranddesign on GitHub (Aug 4, 2023). ### The bug EXIF data has a specific field for the coordinate direction. When XMP file s contain this information, the coordinate is mapped incorrectly. ``` <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.4.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:GPSSpeedRef>K</exif:GPSSpeedRef> <exif:GPSSpeed>0.0</exif:GPSSpeed> <exif:GPSTimeStamp>2009-01-01T00:00:00Z</exif:GPSTimeStamp> <exif:GPSImgDirection>291.76978416999998</exif:GPSImgDirection> <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef> <exif:GPSAltitudeRef>0</exif:GPSAltitudeRef> <exif:GPSLongitude>68</exif:GPSLongitude> <exif:GPSLatitude>60.5</exif:GPSLatitude> <exif:GPSLatitudeRef>N</exif:GPSLatitudeRef> <exif:GPSImgDirectionRef>T</exif:GPSImgDirectionRef> <exif:GPSAltitude>121</exif:GPSAltitude> <exif:GPSHPositioningError>0.0</exif:GPSHPositioningError> </rdf:Description> </rdf:RDF> </x:xmpmeta> ``` Immich currently displays this as in [Russia](https://duckduckgo.com/?q=60.5%252C+68) because it doesn't take into account the `Ref` fields, however the correct location is [Akpatok Island](https://duckduckgo.com/?q=60.5+N%252C+68+W). ### The OS that Immich Server is running on N/A ### Version of Immich Server v1.69.0 ### Version of Immich Mobile App N/A ### Platform with the issue - [X] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML N/A ``` ### Your .env content ```Shell N/A ``` ### Reproduction steps ```bash 1. Use the CLI to import a photo with a sidecar with the contents listed above. ... ``` ### Additional information _No response_
Author
Owner

@waclaw66 commented on GitHub (Aug 5, 2023):

Same here, China instead of US. It doesn't take GPSLongitudeRef into account.

<x:xmpmeta xmlns:x='adobe:ns:meta/'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

 <rdf:Description xmlns:exif='http://ns.adobe.com/exif/1.0/'>
  <exif:ImageWidth>3264</exif:ImageWidth>
  <exif:ImageLength>2448</exif:ImageLength>
  <exif:Make>SAMSUNG</exif:Make>
  <exif:Model>GT-I9300</exif:Model>
  <exif:Orientation>Top-left</exif:Orientation>
  <exif:XResolution>72</exif:XResolution>
  <exif:YResolution>72</exif:YResolution>
  <exif:ResolutionUnit>Inch</exif:ResolutionUnit>
  <exif:Software>I9300XXUGNB6</exif:Software>
  <exif:DateTime>2014:05:30 12:51:53</exif:DateTime>
  <exif:YCbCrPositioning>Centered</exif:YCbCrPositioning>
  <exif:ExposureProgram>Normal program</exif:ExposureProgram>
  <exif:ExifVersion>Exif Version 2.2</exif:ExifVersion>
  <exif:DateTimeOriginal>2014:05:30 12:51:53</exif:DateTimeOriginal>
  <exif:DateTimeDigitized>2014:05:30 12:51:53</exif:DateTimeDigitized>
  <exif:MeteringMode>Center-weighted average</exif:MeteringMode>
  <exif:MakerNote>98 bytes undefined data</exif:MakerNote>
  <exif:FlashPixVersion>FlashPix Version 1.0</exif:FlashPixVersion>
  <exif:ColorSpace>sRGB</exif:ColorSpace>
  <exif:PixelXDimension>3264</exif:PixelXDimension>
  <exif:PixelYDimension>2448</exif:PixelYDimension>
  <exif:ExposureMode>Auto exposure</exif:ExposureMode>
  <exif:WhiteBalance>Auto white balance</exif:WhiteBalance>
  <exif:SceneCaptureType>4</exif:SceneCaptureType>
  <exif:InteroperabilityIndex>N</exif:InteroperabilityIndex>
  <exif:InteroperabilityVersion>37, 37,  7</exif:InteroperabilityVersion>
  <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
  <exif:GPSLongitude>112,  9, 38</exif:GPSLongitude>
 </rdf:Description>

</rdf:RDF>
</x:xmpmeta>
@waclaw66 commented on GitHub (Aug 5, 2023): Same here, China instead of US. It doesn't take `GPSLongitudeRef` into account. ```xml <x:xmpmeta xmlns:x='adobe:ns:meta/'> <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <rdf:Description xmlns:exif='http://ns.adobe.com/exif/1.0/'> <exif:ImageWidth>3264</exif:ImageWidth> <exif:ImageLength>2448</exif:ImageLength> <exif:Make>SAMSUNG</exif:Make> <exif:Model>GT-I9300</exif:Model> <exif:Orientation>Top-left</exif:Orientation> <exif:XResolution>72</exif:XResolution> <exif:YResolution>72</exif:YResolution> <exif:ResolutionUnit>Inch</exif:ResolutionUnit> <exif:Software>I9300XXUGNB6</exif:Software> <exif:DateTime>2014:05:30 12:51:53</exif:DateTime> <exif:YCbCrPositioning>Centered</exif:YCbCrPositioning> <exif:ExposureProgram>Normal program</exif:ExposureProgram> <exif:ExifVersion>Exif Version 2.2</exif:ExifVersion> <exif:DateTimeOriginal>2014:05:30 12:51:53</exif:DateTimeOriginal> <exif:DateTimeDigitized>2014:05:30 12:51:53</exif:DateTimeDigitized> <exif:MeteringMode>Center-weighted average</exif:MeteringMode> <exif:MakerNote>98 bytes undefined data</exif:MakerNote> <exif:FlashPixVersion>FlashPix Version 1.0</exif:FlashPixVersion> <exif:ColorSpace>sRGB</exif:ColorSpace> <exif:PixelXDimension>3264</exif:PixelXDimension> <exif:PixelYDimension>2448</exif:PixelYDimension> <exif:ExposureMode>Auto exposure</exif:ExposureMode> <exif:WhiteBalance>Auto white balance</exif:WhiteBalance> <exif:SceneCaptureType>4</exif:SceneCaptureType> <exif:InteroperabilityIndex>N</exif:InteroperabilityIndex> <exif:InteroperabilityVersion>37, 37, 7</exif:InteroperabilityVersion> <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef> <exif:GPSLongitude>112, 9, 38</exif:GPSLongitude> </rdf:Description> </rdf:RDF> </x:xmpmeta> ```
Author
Owner

@uhthomas commented on GitHub (Aug 6, 2023):

Possibly resolved by https://github.com/immich-app/immich/pull/2908

@uhthomas commented on GitHub (Aug 6, 2023): Possibly resolved by https://github.com/immich-app/immich/pull/2908
Author
Owner

@waclaw66 commented on GitHub (Sep 18, 2023):

Possibly resolved by #2908

Nope, it didn't help.

@waclaw66 commented on GitHub (Sep 18, 2023): > Possibly resolved by #2908 Nope, it didn't help.
Author
Owner

@alextran1502 commented on GitHub (Sep 18, 2023):

@waclaw66 it hasn't been released yet 😅

@alextran1502 commented on GitHub (Sep 18, 2023): @waclaw66 it hasn't been released yet 😅
Author
Owner

@waclaw66 commented on GitHub (Sep 18, 2023):

@waclaw66 it hasn't been released yet 😅

However it was merged to main and tested on my server.

@waclaw66 commented on GitHub (Sep 18, 2023): > @waclaw66 it hasn't been released yet 😅 However it was merged to main and tested on my server.
Author
Owner

@jrasm91 commented on GitHub (Sep 18, 2023):

I'm guessing we're getting the values of the tags, not adjusted by this reference. This might be something we need to manually do during extraction.

@jrasm91 commented on GitHub (Sep 18, 2023): I'm guessing we're getting the values of the tags, not adjusted by this reference. This might be something we need to manually do during extraction.
Author
Owner

@jrasm91 commented on GitHub (Oct 4, 2023):

What is supposed to happen here? The lat/lng need to be updated based on the gps ref? So like negative the coordinates based on the heading, etc.?

@jrasm91 commented on GitHub (Oct 4, 2023): What is supposed to happen here? The lat/lng need to be updated based on the gps ref? So like negative the coordinates based on the heading, etc.?
Author
Owner

@jrasm91 commented on GitHub (Oct 4, 2023):

I can work on this if you can help me understand how the headings work and what should be happening, but I don't have time to research the intricacies of this right now.

@jrasm91 commented on GitHub (Oct 4, 2023): I can work on this if you can help me understand how the headings work and what should be happening, but I don't have time to research the intricacies of this right now.
Author
Owner

@waclaw66 commented on GitHub (Oct 10, 2023):

@jrasm91 The main problem is, that Immich takes Latitude and Longitude from tags.GPSLatitude and tags.GPSLongitude fields only.
2370c9ef41/server/src/domain/metadata/metadata.service.ts (L356)

However those fields can be positive with additional fields GPSLatitudeRef and GPSLongitudeRef that specify NSEW direction. And sometimes (https://github.com/immich-app/immich/issues/4340#issuecomment-1747346735) values can be contradictional between GPSLatitude and GPSLatitudeRef N vs S.

I would propose to extract GPS location from GPSPosition field, that seems to be always correct, it's precalculated from exiftool.

A nice lizzard photo example:
original xmp data:

  <exif:GPSLatitude>18,32.725541N</exif:GPSLatitude>
  <exif:GPSLatitudeRef>S</exif:GPSLatitudeRef>
  <exif:GPSLongitude>70,19.873308E</exif:GPSLongitude>
  <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>

extracted by exiftool within immich:

"GPSLatitude": 18.5454256833722,
"GPSLongitude": 70.331221799975,
"GPSLatitudeRef": "North",
"GPSLongitudeRef": "East",
"GPSPosition": "-18.5454256833722 -70.331221799975",

Returned GPSLatitude, GPSLongitude, GPSLatitudeRef and GPSLongitudeRef fields are incorrect in this example, only GPSPosition -18.5454256833722 -70.331221799975 are correct coordinates.

I've tried to fix it by simple tags.GPSPosition.split(' ') and it works fine on all my misplaced assets. But I'm not TS dev, thus I would let you to fix it.

@waclaw66 commented on GitHub (Oct 10, 2023): @jrasm91 The main problem is, that Immich takes Latitude and Longitude from `tags.GPSLatitude` and `tags.GPSLongitude` fields only. https://github.com/immich-app/immich/blob/2370c9ef41722a198f646c31bfa4c842ebe9c219/server/src/domain/metadata/metadata.service.ts#L356 However those fields can be positive with additional fields `GPSLatitudeRef` and `GPSLongitudeRef` that specify NSEW direction. And sometimes (https://github.com/immich-app/immich/issues/4340#issuecomment-1747346735) values can be contradictional between `GPSLatitude` and `GPSLatitudeRef` N vs S. I would propose to extract GPS location from `GPSPosition` field, that seems to be always correct, it's precalculated from exiftool. A nice lizzard photo example: original xmp data: ```xml <exif:GPSLatitude>18,32.725541N</exif:GPSLatitude> <exif:GPSLatitudeRef>S</exif:GPSLatitudeRef> <exif:GPSLongitude>70,19.873308E</exif:GPSLongitude> <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef> ``` extracted by exiftool within immich: ``` "GPSLatitude": 18.5454256833722, "GPSLongitude": 70.331221799975, "GPSLatitudeRef": "North", "GPSLongitudeRef": "East", "GPSPosition": "-18.5454256833722 -70.331221799975", ``` Returned `GPSLatitude`, `GPSLongitude`, `GPSLatitudeRef` and `GPSLongitudeRef` fields are incorrect in this example, only `GPSPosition` `-18.5454256833722 -70.331221799975` are correct coordinates. I've tried to fix it by simple `tags.GPSPosition.split(' ')` and it works fine on all my misplaced assets. But I'm not TS dev, thus I would let you to fix it.
Author
Owner

@jrasm91 commented on GitHub (Oct 10, 2023):

Ok, perfect. Thanks for the explanation.

@jrasm91 commented on GitHub (Oct 10, 2023): Ok, perfect. Thanks for the explanation.
Author
Owner

@BigCheeZ commented on GitHub (Jan 21, 2024):

Has anyone else confirmed this is fixed? I have updated my existing instance to Immich v1.93.3, run the Sidecar Metadata job, and the Extract Metadata jobs. I see no difference from before. My media that uses XMP files with GPSLatitudeRef and GPSLongitudeRef are still incorrect. Am I missing steps to make this work?

@BigCheeZ commented on GitHub (Jan 21, 2024): Has anyone else confirmed this is fixed? I have updated my existing instance to Immich v1.93.3, run the Sidecar Metadata job, and the Extract Metadata jobs. I see no difference from before. My media that uses XMP files with GPSLatitudeRef and GPSLongitudeRef are still incorrect. Am I missing steps to make this work?
Author
Owner

@waclaw66 commented on GitHub (Jan 21, 2024):

Has anyone else confirmed this is fixed? I have updated my existing instance to Immich v1.93.3, run the Sidecar Metadata job, and the Extract Metadata jobs. I see no difference from before. My media that uses XMP files with GPSLatitudeRef and GPSLongitudeRef are still incorrect. Am I missing steps to make this work?

Please post example image, I can check it on my instance.

@waclaw66 commented on GitHub (Jan 21, 2024): > Has anyone else confirmed this is fixed? I have updated my existing instance to Immich v1.93.3, run the Sidecar Metadata job, and the Extract Metadata jobs. I see no difference from before. My media that uses XMP files with GPSLatitudeRef and GPSLongitudeRef are still incorrect. Am I missing steps to make this work? Please post example image, I can check it on my instance.
Author
Owner

@BigCheeZ commented on GitHub (Jan 21, 2024):

@waclaw66 please see JPG and XMP file in the zip file attached below. The JPG actually has the accurate EXIF data inside the file. The XMP files does too, but when it is parsed by Immich it results in the location being shown as Nepal (see below) instead of Orlando, FL USA because GPSLongitudeRef is not being handled appropriately.

Birendranagar
Surkhet, Karnali Pradesh
Nepal

immich-xmp-test.zip

@BigCheeZ commented on GitHub (Jan 21, 2024): @waclaw66 please see JPG and XMP file in the zip file attached below. The JPG actually has the accurate EXIF data inside the file. The XMP files does too, but when it is parsed by Immich it results in the location being shown as Nepal (see below) instead of Orlando, FL USA because GPSLongitudeRef is not being handled appropriately. Birendranagar Surkhet, Karnali Pradesh Nepal [immich-xmp-test.zip](https://github.com/immich-app/immich/files/14002230/immich-xmp-test.zip)
Author
Owner

@waclaw66 commented on GitHub (Jan 21, 2024):

This issue is about embedded xmp file in the jpeg file, your issue seems to be something else. I'm not sure how Immich handles external xmp files.

@waclaw66 commented on GitHub (Jan 21, 2024): This issue is about embedded xmp file in the jpeg file, your issue seems to be something else. I'm not sure how Immich handles external xmp files.
Author
Owner

@MrColumbo commented on GitHub (Feb 4, 2024):

i once opened up [BUG] Wrong location on map #4340 ....not quite sure if this is one is different as well. At least i did not use a sidecar file. In my case the lizzard is still shown at the wrong place on the map.
I never was able to see the wrong gps coordintes by using exiftool .....also every other photo app shows it correctly ...

@MrColumbo commented on GitHub (Feb 4, 2024): i once opened up [BUG] Wrong location on map #4340 ....not quite sure if this is one is different as well. At least i did not use a sidecar file. In my case the lizzard is still shown at the wrong place on the map. I never was able to see the wrong gps coordintes by using exiftool .....also every other photo app shows it correctly ...
Author
Owner

@waclaw66 commented on GitHub (Feb 4, 2024):

I can see that lizzard in Chile as expected...
obrazek
It was fixed by workaround within exiftool-vedored.js in this case (https://github.com/immich-app/immich/pull/6138).

@waclaw66 commented on GitHub (Feb 4, 2024): I can see that lizzard in Chile as expected... ![obrazek](https://github.com/immich-app/immich/assets/15554561/2730ca40-c658-4af3-822b-52d11834ef21) It was fixed by workaround within exiftool-vedored.js in this case (https://github.com/immich-app/immich/pull/6138).
Author
Owner

@MrColumbo commented on GitHub (Feb 4, 2024):

oh - i just uploaded it again and this time it shows it correctly as well. Before i just did a refresh on the metadata for this single photo. I will try to do a full read metadata job again (maybe refresh metadata does not mean to read it again???)

@MrColumbo commented on GitHub (Feb 4, 2024): oh - i just uploaded it again and this time it shows it correctly as well. Before i just did a refresh on the metadata for this single photo. I will try to do a full read metadata job again (maybe refresh metadata does not mean to read it again???)
Author
Owner

@waclaw66 commented on GitHub (Feb 4, 2024):

Refresh metadata should be sufficient to reload correct gps position.

@waclaw66 commented on GitHub (Feb 4, 2024): Refresh metadata should be sufficient to reload correct gps position.
Author
Owner

@MrColumbo commented on GitHub (Feb 5, 2024):

after i did ran the extract meta job it looks all right - thanks.
Not quite sure why I did not seem to work when i did click on the 3 dots a refresh metadata. Those pictures are part of an external library.
Anyway ....now it looks fine :) -thanks

@MrColumbo commented on GitHub (Feb 5, 2024): after i did ran the extract meta job it looks all right - thanks. Not quite sure why I did not seem to work when i did click on the 3 dots a refresh metadata. Those pictures are part of an external library. Anyway ....now it looks fine :) -thanks
Author
Owner

@thegranddesign commented on GitHub (Sep 15, 2025):

For those who come to this issue later, there is an additional issue with Apple Photos exporting (or at least there was when I did it). This is not something that Immich is going to fix but you can fix it by running an exiftool command against your photo metadata.

exiftool -P -overwrite_original -ext xmp -XMP-exif:All= -tagsFromFile @ -XMP-exif:All '-XMP-exif:GPSLongitude<${XMP-exif:GPSLongitude#}${XMP-exif:GPSLongitudeRef#}' '-XMP-exif:GPSLatitude<${XMP-exif:GPSLatitude#}${XMP-exif:GPSLatitudeRef#}' .

What does this command do?

-P: Preserve modification times
-overwrite_original: Overwrite the original metadata file
-ext xmp: Process files with this extension
-XMP-exif:All=: Specify which XMP data to read and write
-tagsFromFile @: Read tags from the source file being processed
-XMP-exif:GPSLongitude<${XMP-exif:GPSLongitude#}${XMP-exif:GPSLongitudeRef#}: Write the longitude by taking the longitude from the source file and follow it by the longitude ref from the source file. Effectively combining them.
-XMP-exif:GPSLatitude<${XMP-exif:GPSLatitude#}${XMP-exif:GPSLatitudeRef#}: Write the latitude by taking the latitude from the source file and follow it by the latitude ref from the source file. Effectively combining them.
.: Process all files in the current directory

@thegranddesign commented on GitHub (Sep 15, 2025): For those who come to this issue later, there is an additional issue with Apple Photos exporting (or at least there was when I did it). This is not something that Immich is going to fix but *you* can fix it by running an `exiftool` command against your photo metadata. ```sh exiftool -P -overwrite_original -ext xmp -XMP-exif:All= -tagsFromFile @ -XMP-exif:All '-XMP-exif:GPSLongitude<${XMP-exif:GPSLongitude#}${XMP-exif:GPSLongitudeRef#}' '-XMP-exif:GPSLatitude<${XMP-exif:GPSLatitude#}${XMP-exif:GPSLatitudeRef#}' . ``` What does this command do? `-P`: Preserve modification times `-overwrite_original`: Overwrite the original metadata file `-ext xmp`: Process files with this extension `-XMP-exif:All=`: Specify which XMP data to read and write `-tagsFromFile @`: Read tags from the source file being processed `-XMP-exif:GPSLongitude<${XMP-exif:GPSLongitude#}${XMP-exif:GPSLongitudeRef#}`: Write the longitude by taking the longitude from the source file and follow it by the longitude ref from the source file. Effectively combining them. `-XMP-exif:GPSLatitude<${XMP-exif:GPSLatitude#}${XMP-exif:GPSLatitudeRef#}`: Write the latitude by taking the latitude from the source file and follow it by the latitude ref from the source file. Effectively combining them. `.`: Process all files in the current directory
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#1184