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

Add Export of metadata via XMP Sidecar #984

Merged

Conversation

chkuendig
Copy link
Contributor

@chkuendig chkuendig commented Nov 1, 2024

There have been multiple requests over time ( #448, #102, #789, probably more) to export some of the metadata that can be changed in Photos. This PR tries to address as many of these as possible but focused on the most common ones:

  • Time adjustments
  • Location Adjustments
  • Hidden and Deleted Photos
  • Title and Description
  • Changed Rotation
  • Tags/Keywords

I tested this on my 50'000+ images library and it processed all of them. If the Exif Tags are supported by Immich they also match. (this helped a ton to sort the images in the correct order and add missing location tags to pictures taken without embedded location info - e.g. from DSLR etc)

PS: This also would replace/close #915 I guess.

@chkuendig chkuendig changed the title Add Export of metadata via XMP Sidecar Add Export of metadata via XMP Sidecar via Exiftool Nov 1, 2024
@AndreyNikiforov
Copy link
Collaborator

Thanks for taking initiative. Appreciate writing tests for new features.

Can you implement all these features without external dependency on exiftool, pls? icloudpd is distributed as standalone binary without any dependencies on all platforms and there is value in keeping it that way.

@chkuendig
Copy link
Contributor Author

chkuendig commented Nov 2, 2024

I understand the preference to keep this working without any external dependencies. Unfortunately for XMP handling I couldn't find a single library that wouldn't need external dependencies. I specifically looked at:

I couldn't find a single pure python library and I don't really have the bandwith to implement a fairly complex standard from scratch just for this. If any of the other 2 libraries are okay, I'm happy to re-implement the PR. Or maybe there's a better way I'm not aware of? Like many I use docker so external depencendies aren't really an issue for me.

@AndreyNikiforov
Copy link
Collaborator

is it reasonable too generated xmp file just from metadata received from Apple (without exif at all)? xmp will have to bed generated with the code i assume

@chkuendig
Copy link
Contributor Author

Thats what I'm doing, I use exiftool just to write the sidecar file.

I'll check if its feasible to just write the XML by hand. As long as we stick to the +/- 10 fields, its cumbersome but probably doable by just generating the xml once with exiftool and then write code to replicate it in pure python.

@AndreyNikiforov
Copy link
Collaborator

what happens when metadata is updated in icloud? should local xmp be synchronized? what if local changed as well?

@chkuendig
Copy link
Contributor Author

I currently assumed this to be mostly an archival function, so the iCloud data would overwrite local data.

Thinking more about this, I'd suggest we check the XMLToolkit tag to make sure the last edit was by icloudpd. It seems to be a tag thats changed if edited by another software.

I'll add this with the update to remove external dependencies.

@chkuendig chkuendig changed the title Add Export of metadata via XMP Sidecar via Exiftool Add Export of metadata via XMP Sidecar Nov 25, 2024
@chkuendig
Copy link
Contributor Author

chkuendig commented Nov 25, 2024

I pushed an update that removes the dependency on exitfool and also checks if an xmp file exists before overwriting it (it only overwrites if the file is empty or was generated by icloudpd in the first place)

note: I updated the lint python version to 3.9 so I can use ElementTree.indent

@AndreyNikiforov
Copy link
Collaborator

note: I updated the lint python version to 3.9 so I can use ElementTree.indent

Does that mean we have to drop support for 3.8?

@chkuendig
Copy link
Contributor Author

Yes. If thats an issue i'd suggest to remove that call and output unformatted xml instead.

@AndreyNikiforov
Copy link
Collaborator

Yes. If thats an issue i'd suggest to remove that call and output unformatted xml instead.

Thanks! I think maintaining 3.8 compatibility is higher value than pretty printed small xml file (which is not supposed to be viewed by humans)

@chkuendig
Copy link
Contributor Author

chkuendig commented Nov 28, 2024

Done.

PS: I also found a bug in the orientation field (it did not reflect possible adjustments). This should be corrected now.

@chkuendig chkuendig force-pushed the xmp-sidecar branch 2 times, most recently from c75f162 to 4eefa8f Compare November 29, 2024 12:21
@AndreyNikiforov AndreyNikiforov merged commit fda998d into icloud-photos-downloader:master Nov 29, 2024
372 checks passed
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

Successfully merging this pull request may close these issues.

2 participants