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

feat: extract City/State/Country from IPTC tags #15344

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gytisgreitai
Copy link

This PR enables extracting Locality information (City/State/Country) from exif IPTC tags instead of relying on reverse geocoding.
This also skips reverse geocoding if any of those tags are set and just uses their values.

Why this change? I have bunch of photos from Alps where there are no bigger cities nearby, so Immich fails to reverse geocode the location, so I've set them directly into the photos by using Google Places API and now want to upload and display them in Immich. Reasoning behind this change and more info can be found in this discussion #15270

To set those tags on an JPG you can use exiftool, e.g.:

exiftool -IPTC:City=Caprile -IPTC:Province-State=Veneto -IPTC:Country-PrimaryLocationCode=ITA -IPTC:Country-PrimaryLocationName=Italy image.jpeg

Which then can be viewed in any image editor:
image

And which is extracted once uploaded to Immich:
image

Things I'm not sure about:

  • Added single test, not sure if more are needed
  • Behaviour of skipping reverse geocoding if any of the tags is set (e.g. perhaps I would like to have more detailed reverse geocoding to fill in the City if only Country is present)
  • Using StringOrNumber (assumed those are as Description tags)

Any feedback welcome.

@github-actions github-actions bot added documentation Improvements or additions to documentation 🗄️server labels Jan 14, 2025
@bo0tzz bo0tzz changed the title Extract City/State/Country from IPTC tags feat: extract City/State/Country from IPTC tags Jan 14, 2025
Copy link
Contributor

📖 Documentation deployed to pr-15344.preview.immich.app

@alextran1502
Copy link
Contributor

Hello, can you please help fix the failed tests?

@bo0tzz
Copy link
Member

bo0tzz commented Jan 14, 2025

Lovely stuff! Did you look at writing this data into sidecars when Immich does reverse geocoding as well? No worries if not.

@gytisgreitai
Copy link
Author

Just I'm not sure why they broke. From the logs I only see

   ✓ /asset > GET /assets/:id > should get the asset faces 372ms
   × /asset > PUT /assets/:id > should update date time original when sidecar file contains DateTimeOriginal 10008ms
     → Timed out waiting for queue to empty

@gytisgreitai
Copy link
Author

gytisgreitai commented Jan 14, 2025

Lovely stuff! Did you look at writing this data into sidecars when Immich does reverse geocoding as well? No worries if not.

no, sorry, not sure on the concepts of sidecars, this whole stuff is quite new to me

@gytisgreitai
Copy link
Author

Ok so I guess one of the issues is that the e2e test asset
https://github.com/immich-app/test-assets/blob/main/metadata/gps-position/thompson-springs.jpg
contains metadata and it is now used instead of reverse geocoding and assertions fail. That could be fixed by removing that metadata so that it uses reverse geocoding and then adding a new file to test the tag reading (though not sure if this PR warrants an e2e test at all?)
I also have quite some other e2e errors running locally which I cannot work out why they fail

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:feature documentation Improvements or additions to documentation 🗄️server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants