Skip to main content
mr_fluffy
Participating Frequently
January 28, 2016
Question

I need to add some data to a photo

  • January 28, 2016
  • 1 reply
  • 814 views

I think that create a companion XML file with datas and open It with a plugin action to show data is the best way, but If someone import photo to a catalog moving them to catalogs folder, XML remain in original folder. Also, if someone rename a photo, I can't access anymore the photoname.xml. How to resolve this? I only want to have always a companion data's file with my photo, even if people import and move to a catalog photos or rename them.

This topic has been closed for replies.

1 reply

johnrellis
Legend
January 28, 2016

Instead of a companion .xml file, you could store your data in industry-standard XMP in a custom schema.   The XMP for JPEG, TIFFs, DNGs, PNGs, and videos is stored inside the file, and the XMP for raw files is stored in a sidecar .xmp file.  Storing the data in XMP ensures that it will stay with the file if you rename, move, or import photos inside LR.

Your plugin could invoke the free Exiftool to read and write the metadata. Before writing the metadata to the file, your plugin could invoke the undocumented photo:saveMetadata()  to do the equivalent of Metadata > Save Metadata To File.

I think it will take a couple hours to figure out how to configure Exiftool to read and write custom XMP schemas, but it looks pretty well documented.

mr_fluffy
mr_fluffyAuthor
Participating Frequently
January 29, 2016

Your're right, we have tried to implement them with XMP but we have some problem. There is some possibilities to write down data inside Lightroom database, associate them with a photo file and then read them from the database?

johnrellis
Legend
January 29, 2016
There is some possibilities to write down data inside Lightroom database, associate them with a photo file and then read them from the database?

Yes, plugins can create custom metadata fields for photos in the database.  See Chapter 4: Working With Metadata in the LR SDK Guide.

Custom metadata can be very useful, but it doesn't meet all your requirements.  If you add custom metadata to a photo and then import that photo into a new catalog, the custom metadata won't transfer (because it is stored in the catalog, not the photo's file).