Copy link to clipboard
Copied
Hey,
for a plugin I would like to remember some photos that were used for an operation. I thought that saving the photo.localIdentifier would be the best way to get me access to the LrPhoto again at a later point, however, there doesn't seem to be any way to do a lookup based on localIdentifier. The only option I see is the UUID, which is available via photo:getRawMetadata , which requires being inside an LrTask.
Two questions:
1) Is UUID the recommended way to remember a photo reference?
2) If yes, what's the point of photo.localIdentifier ? Only for debugging?
Martin
"1) Is UUID the recommended way to remember a photo reference?"
If you want a reference to a photo that can be easily translated back to the LrPhoto, use the UUID and catalog:findPhotoByUuid().
You could use .localIdentifier, but to translate it back to an LrPhoto, you'd need to use catalog:getAllPhotos() to build a table mapping localIdentifier back to LrPhoto (which goes fairly fast, on the order of tens of thousands of photos per second, but slow enough that you might want to cache the mappin
...Copy link to clipboard
Copied
"1) Is UUID the recommended way to remember a photo reference?"
If you want a reference to a photo that can be easily translated back to the LrPhoto, use the UUID and catalog:findPhotoByUuid().
You could use .localIdentifier, but to translate it back to an LrPhoto, you'd need to use catalog:getAllPhotos() to build a table mapping localIdentifier back to LrPhoto (which goes fairly fast, on the order of tens of thousands of photos per second, but slow enough that you might want to cache the mapping table in a global variable).
If you're writing a large number of references in a text file, .localIdentifier would cut down on the number of bytes written.
"2) If yes, what's the point of photo.localIdentifier ? Only for debugging?"
It's lost in prehistory. In general the SDK is an unfinished work-in-progress, with very little effort devoted to it since LR 3.
Copy link to clipboard
Copied
Thank you for the quick response and insights!
Building my own in-memory table of all photos seems like a lot of work and may hit memory limits. I suppose if I expect to look up a large fraction of the catalog, it might be faster than repeated findPhotoByUuid, but fortunately that's unlikely in my use case (and in the end I need to export the found photos... that will dominate the time spent anyways.)