Lightroom SDK: Impossible to reset CameraProfile with LrDevelopController

  • 2
  • Problem
  • Updated 9 months ago
  • (Edited)
I am writing a very simple plugin to be able to reset the CameraProfile setting in Develop module.

Even "CameraProfile" is returned correctly by photo:getDevelopSettings(), looks like resetting it with LrDevelopController doesn't do anything:
local LrDevelopController = import 'LrDevelopController'
LrDevelopController.resetToDefault( "CameraProfile" )
Is it not possible to reset only the Camera Profile setting in any way?
Photo of Kyopaxa

Kyopaxa

  • 3 Posts
  • 0 Reply Likes
  • sad, confused

Posted 9 months ago

  • 2
Photo of John R. Ellis

John R. Ellis, Champion

  • 3378 Posts
  • 849 Reply Likes
Interesting.  You can't change the value either:
LrDevelopController.setValue ("CameraProfile", "Adobe Standard")
returns without error but has no effect when the current profile is different.

photo:applyDevelopSettings() appears to change the profile correctly, e.g.
photo:applyDevelopSettings ({CameraProfile = "Adobe Standard"})
Some experimentation shows that this will reset the profile to its default value: 
photo:applyDevelopSettings({CameraProfile = ""})
All undocumented, of course.
(Edited)
Photo of Kyopaxa

Kyopaxa

  • 3 Posts
  • 0 Reply Likes
Thanks for the info John! Very valuable. I finally managed to do it with photo:applyDevelopSettings({CameraProfile = ""}). Unfortunately, I did not achieve what I was really after, which is to reset the +/- icon stating that the photo has develop settings. (The one that appears on the lower right corner of the thumbnails).

See, I have more than 10K pictures with the CameraProfile manually set to "Camera Standard", which is also my default profile. All of them show the +/- icon, and I thought that maybe resetting their CameraProfile would remove the damn icon. Turns out is not the case... Also, I can't fully reset the photos since hundreds of them also have other develop settings that I want to keep. This is a nightmare...

I was thinking, now that I can apply develop settings with photo:applyDevelopSettings({table}), maybe I can iterate over all photos and:
  1. Get their settings table with getDevelopSettings
  2. Remove all settings from the table that have default values, including CameraProfile.
  3. Reset the photo to default.
  4. Apply the settings only to those that have values remaining in the table from step 2.
Problem is that I don't know how to reset photo settings to default directly from the LrPhoto object. The documentation does not state any method to do that. Is it only possible to do it from LrDevelopController?
(Edited)
Photo of John R. Ellis

John R. Ellis, Champion

  • 3378 Posts
  • 849 Reply Likes
I did a few more experiments. I think this will work: First call LrApplicationView.switchToModule() to switch to Develop.  Then for each photo in turn:

1. Select photo with catalog:setSelectPhotos().

2. Call photo:getDevelopSettings() to get the current settings.

3. Call LrDevelopController.resetDevelopAdjustments() (which does appear to set CameraProfile to default).

4. Call photo:getDevelopSettings() to determine the default values for each develop setting.

5. Determine the non-default settings of the photo by comparing the results of steps 2 and 4.

6. Apply the non-default settings with photo:applyDevelopSettings().

Note that this will add two entries to the History panel for each photo, for steps 3 and 6. 

It wouldn't surprise me if this is fragile, perhaps behaving unpredictably if you try to do more than a couple of photos. The SDK has a number of dark corners containing race conditions, and I and at least another developer have found it necessary over the years to add carefully placed LrTasks.sleep(0) calls and spin loops waiting for settings to "take".
Photo of Kyopaxa

Kyopaxa

  • 3 Posts
  • 0 Reply Likes
Haha, funny, just right now I finished to do exactly all what you say, including fighting those race conditions you talk about (mainly caused by having to rely on the damn LrDevelopController thing, which forces me to modify the selection...). I didn't know about LrTasks.sleep() by the way, I was using my ugly sleep function, thanks for the tip!

If the SDK had a photo:getDefaultDevelopSettings(), photo:setDefaultDevelopSettings() and even a photo:getTouchedDevelopSettings() my life would be 10000% much easier... Also, if after resetting a setting, the resulting photo is the same as the default, the +/- icon should disappear!

Only thing different I did was your step 6. Instead of applying settings, what I do is to LrUndo.undo() for those photos with settings I want to keep. The rest I keep them reset.

Good to mention too that for some pictures, after issuing LrDevelopController.resetDevelopAdjustments(), the Temperature and the Tint were not returned with photo:getDevelopSettings() for some reason. I had to get it manually with LrDevelopController.getValue().

Right now, I have a "kind of working, super crappy, super slow" script... Thank you very much!
(Edited)