-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
GPS geo location wrong: GPSLongitudeRef and GPSLatitudeRef not taken into account #13053
Comments
After digging trough the map view I saw it has way more images of location then I thought. I did the import to Immich over the cli to also import the xml file. And it looks like it is not using the fields for GPSLongitudeRef correct. Because when I post the Lat, LNG Data straight to google maps it also shows wrong location like 28°11'04.1"N 14°09'38.4"E But it should be West, not East. When I change E to W at the end in google it is the right location. Maybe that helps? |
There's actually a TODO comment in the code for this :P immich/server/src/services/metadata.service.ts Lines 658 to 662 in 5bcbe77
|
So any plan TODO the in the near future :-), makes my map look really weird. And I am sure we have to reimport our data, or will there be an update button for the map data? |
It'll be done whenever someone decides to work on it ;) You can re-extract metadata by running the appropriate job from the admin panel, so there will be no need to reimport anything. |
@skycryer I am kind of a newbie here but maybe this can help. I was looking into this and seems that the issue might actually be the XMP itself not the code. I did a few trial and error upload of pictures while modifying the exif data and the exiftool seems to behave correctly by default, so after looking into the XMP, I found this: In the exif metadata XMP specification it shows that the tags GPSLongitudeRef and GPSLatitudeRef are not used I believe you will have to append what is in GPSLongitudeRef in GPSLongitude and the same for GPSLatitude |
The information might not be stored in XMP, it might be in EXIF only. I imagine the Can you provide an example image that exhibits the issue? Can also run exiftool on an image with the issue with the following arguments to see actual tags/locations: |
exiftool-vendored contains a test for this situation (positive number for west longitude): As you can see, the positive longitude is returned (and not transformed into the negative one), and the result includes a warning. It seems there's a good reason to reject this input instead of fixing it (or "tak[ing] ref into account" as per the TODO). |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Hi, new contributor here. Thanks for the helpful comments above. I've been investigating this and AFAICT the root cause is that exiftool ignores GPSLatitudeRef and GPSLongitudeRef in XMP data when doing a "normal" read. Thanks @dreadster3. Regardless of what value the XMP data contains for GPSLongitudeRef ("W" | "West" | "Kermit"), exiftool will always output "East" or "E". This is true of both exiftool-vendored and exiftool cli. According to the exiftool forums this is by design - because the GPSLat/LongRef tags are invalid it will ignore them and determine their values from the values in GPSLatitude and GPSLongitude themselves. These need to be either signed numbers or have a trailing "W" | "E" | "N" | "S". In this case they have neither, so the positive value for GPSLatitude is used to infer "East". I guess one approach here is to say that the XMP data is invalid and leave as-is, but if this data is created by some popular tool then trying to handle it may be a better option to avoid creating bad experiences for users of that tool. I've created a PR demonstrating attempting to handle the provided XMP data, using the "-e" switch for exiftool in order to read the values of the GPSLat/LongRef tags "raw" from the XMP file. It does use two reads of the sidecar (the second one being the raw read) which I'm not thrilled about, but I wanted to avoid affecting the values for other tags and just use the raw values for GPSLat/LongRef - if they are valid. Following that the GPSLat/LongRef tags become available in getGeo() at the TODO line pointed out by @bo0tzz and they can be taken into account when doing the reverse geocode. |
@aehiggi are there any popular tools you know of that do this? I'm hesitant to include a "fix" that exiftool itself has decided against. We try wherever possible to avoid these kind of custom fixes as they can cause more harm than good. Exiftool vendored also decided against making changes to support this for similar reasons. |
I did an export of apple Photos and generated the xml files where I got that problem of West/East GPS Locations |
@zackpollard I completely understand but it would be good if Immich could help innocent users who end up with XMP files like this. An alternative solution could be to enable users to correct the data themselves through the UI. Perhaps an extension to the Change Location dialog adding something like "Swap E <-> W" and "Swap N <-> S", so they can change the hemisphere for one or a batch of images, without affecting the Lat/Long values themselves. |
I'd urge Apple to fix their code. While that's not done, feel free to fix the files using some kind of tool, possibly as a plugin to Immich (no idea if that's feasible, just an idea). I don't think that Immich should support broken data. |
Apple Photos users: discussion of this issue and tips on fixing your XMP files over at the apple forums https://discussions.apple.com/thread/255792059?answerId=260820004022#260820004022 |
Great! Then let's wait for Apple to fix their software? |
You should be using the geolocation feature if you need location metadata: https://photostructure.github.io/exiftool-vendored.js/interfaces/ExifToolOptions.html#geolocation Back to the topic: it turns out ExifTool has magick that fixes the Apple XMP GPS, but only if geolocation is enabled. The next release of exiftool-vendored will use the hemisphere from |
There's a misunderstanding on the location name - it's determined in Immich using data from the geonames database, not with tz-lookup. No issues there ;) |
The bug
So I have it looks like around 1k images that are shown on the wrong place on the map. I checked my Apple Photos and Export data. All have the correct gps data and are shown correct on Apple Photos. But on Immich they are completely off, not just a few miles but a few thousand.
Here is the metadata of the image
The majority of my images seem to be on the correct location on the map, but this 1k are not. I have no idea why.
The OS that Immich Server is running on
Ubuntu 22.x
Version of Immich Server
v116.2
Version of Immich Mobile App
latest
Platform with the issue
Your docker-compose.yml content
https://github.com/alexbelgium/hassio-addons/tree/master/immich
Your .env content
Reproduction steps
Add the gps data from the xml file, see above, and you see the image will be located in Lybia, not on Fuerteventrura,
Relevant log output
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: