Skip to main content
New Participant
May 10, 2012
Answered

Checking if a photo has adjustments

  • May 10, 2012
  • 2 replies
  • 5493 views

Hi,

I am developing an export filter and I'm looking for a way to determine if an LRPhoto has any adjustments applied (i.e. if the "Photo has Develop adjustments" icon is displayed).

Since I couldn't find anything in the API, I am now using LRPhoto:getDevelopSettings() and check if some common settings are different from their default.

Of course, this is quite fragile, so I'd like to know if there is a better way to do that.

This topic has been closed for replies.
Correct answer johnrellis

Invoke catalog:findPhotos() with the criterion "hasAdjustments = true AND filename starts with <filename>", then test whether the photo is in the array of photos returned.  This should be pretty fast to invoke for each photo in question.  If not, you can invoke it on the entire catalog and cache the results.

2 replies

Known Participant
May 25, 2012

The solution works good, but has a severe performance impact.

I tested it on 1500 photo's and my loop with and without increased from 11 seconds to 90 seconds.

This is an expensive operation.

Something tells me there should be a quicker way, but I have not found it yet.

BTW why do you suggest  filename starts with <filename>" and not contains all?

I used the code below where "name" is the name from the photo:

local name = photo:getFormattedMetadata( "fileName" )

local foundPhotos = catalog:findPhotos {

     searchDesc = {

        {

            criteria = "hasAdjustments",

            operation = "isFalse",

            value = true,

        },

        {

            criteria = "filename",

            operation = "all",

            value = name,

            value2 = "",

        },

        combine = "intersect",

     }

}   

areohbee
Brainiac
May 25, 2012

Did you try John's 2nd idea (doing once for whole catalog), then convert the array returned into a lookup table, so you don't have to go searching through a big array over and over.

?

Known Participant
May 25, 2012

Hi Rob,

Still, I find it strange that in there is not a "hasAdjustments" in photo:getDevelopSettings(). That would solve this problem.

I checked it with the debug toolkit from John Ellis.

You are right, I should try the 2e solution. Thanks.

My plugin loops through a group of selected photos (<= 1500). It checks if a photo has adjustments.

A photographer college has 2 catalogs of each 150K. As far as I understand the catalog:findPhotos function works on an entire catalog. That would mean it would retrieve all photos with no adjustments.

Probably that would be more than 100K for him. Would it then still be faster?

johnrellis
johnrellisCorrect answer
Brainiac
May 10, 2012

Invoke catalog:findPhotos() with the criterion "hasAdjustments = true AND filename starts with <filename>", then test whether the photo is in the array of photos returned.  This should be pretty fast to invoke for each photo in question.  If not, you can invoke it on the entire catalog and cache the results.

ThenedusAuthor
New Participant
May 10, 2012

Thanks, John. Your solution works like a charm and is fast enough.

areohbee
Brainiac
May 10, 2012

Dunno if has-adjustments is asserted simply for non-Adobe defaults (is it?). I assume it will be asserted if a develop preset is applied upon import.