RhetTbull / osxphotos

Python app to work with pictures and associated metadata from Apple Photos on macOS. Also includes a package to provide programmatic access to the Photos library, pictures, and metadata.
MIT License
2.04k stars 96 forks source link

Information exchange between Photos and other Apps #320

Open narensankar0529 opened 3 years ago

narensankar0529 commented 3 years ago

Wondering if there is a way osxphotos can support the following scenario -

The intent is to have a way to use multiple apps to access the Photos data. Since presumably Apple will keep improving its ML algorithms and hence generate better keywords and/or metadata. So not possible to just use --update --ignore-signature

And with the advent of ProRAW, there is also reason to export RAW v/s JPEG

However many other applications tend to use XMP files for holding metadata - Lightroom, C1, Mylio all do this - especially for RAW files.

So if I export from osxphotos with XMP sidecars and then if these files are imported by the other apps and they write to the XMP, this will get overwritten by osxphotos the next time export runs.

So it is not clear to me how to use a process to sync metadata between Photos and say Lightroom using osxphotos as the intermediary especially for RAW files. For JPEG the workaround is to write the data to the image file itself. But for RAW this doesn't work.

Without having a way to merge XMP data, it is not clear to me how to implement an automatic way to go from Photos to other applications which would touch the XMP data.

Any suggestions on this? or is there a way to implement XMP merge like how Lightroom does - i.e. read and merge and then write?

RhetTbull commented 3 years ago

It would be possible to add a --sidecar-merge or --merge-XMP option but this would require that osxphotos be able to read and parse XMP files. Currently, it' handling of XMP files is very "dumb" -- it uses a template for a pre-generated XMP file that just gets filled in with the correct metadata on export.

I've not found any good way to do this in Python. There is Python XMP Toolkit but in my testing this only reads/write XMP embedded in the image file, not the actual .XMP sidecar.

This would be a fairly big change to the way osxphotos handles sidecars now (one way / write only) and would be a big effort. I can see how this would be a useful feature but I've got a number of other issues that are higher priority. I'll keep this open as a "back burner" issue in case someone wants to tackle it.

narensankar0529 commented 3 years ago

Potential solution -

Use the exiv2 library with a python wrapper -

https://pypi.org/project/py3exiv2/

https://dev.exiv2.org/boards/3/topics/2040

RhetTbull commented 3 years ago

I looked at this but it seems designed for manipulating data in image files and lacked support for manipulation of XML sidecars