Skip to main content
Photo Taco Podcast
Known Participant
August 25, 2022
Question

SDK: -Lua reset development settings on photo

  • August 25, 2022
  • 2 replies
  • 331 views

I have a need in my plugin to reset the adjustmentPanel settings in the Develop module for a group of photos (all photos in my code example).  Essentially I want to replicate the functionality of what the Reset button does in the Develop module across many images.  None of the functions in the SDK seem to offer the same work as what the Reset button does for even a single photo, but based on some examples I have found in this community it seems like the following should come close enough for my purposes:

 

 

local LrApplication = import "LrApplication"
local LrTasks = import "LrTasks"
local LrProgressScope = import "LrProgressScope"

local settings = {
  Exposure = 0,
  Contrast = 0,
  Highlights = 0,
  Shadows = 0,
  Whites = 0,
  Blacks = 0,
  Texture = 0,
  Clarity = 0,
  Dehaze = 0,
  Vibrance = 0,
  Saturation = 0
}

LrTasks.startAsyncTask(function()
  local catalog = LrApplication.activeCatalog()
  local allPhotos = catalog:getAllPhotos()

  local portionComplete = 0
  local progressScope = LrProgressScope({ title = 'Resetting All Photos' })
  progressScope:setCaption('Resetting all photos')

  catalog:setActiveSources(catalog.kAllPhotos)
  LrTasks.sleep(1)
  for i = 1, #allPhotos, 1 do
    if progressScope:isCanceled() then return end
    catalog:withWriteAccessDo("Reset Basic Settings", function()
      allPhotos[i]:applyDevelopSettings(settings, "Reset Settings", true)
    end, { timeout = 0.5, asynchronous = false })
    portionComplete = portionComplete + 1
    progressScope:setPortionComplete(portionComplete, #allPhotos)
  end
  progressScope:done()
end)

 

 

This lua code seems to run fine as far as I can tell, but all of the images have the same settings in the adjusmentPanel afterward.  Though history on each image does indeed have a "Reset Settings" entry for each.  Any help on what may be the issue here or if there is a better way to reset settings on a group of photos (collection, selection, all in catalog) would be greatly appreciated.

 

Tested on LR 11.4.1 / Mac OS 12.4.1

This topic has been closed for replies.

2 replies

Photo Taco Podcast
Known Participant
August 26, 2022

I found this issue with this code.  The names I was using were those that match the Develop module and those in the LrDevelopController documentation.  Most of them need a 2012 appended to the end of them as is shown in the LrPhoto documentation under the photo:getDevelopSettings method.  Changd my settings variable to this and now the process works as I need for my plugin:

local settings = {
  Exposure2012 = 0,
  Contrast2012 = 0,
  Highlights2012 = 0,
  Shadows2012 = 0,
  Whites2012 = 0,
  Blacks2012 = 0,
  Texture = 0,
  Clarity2012 = 0,
  Dehaze = 0,
  Vibrance = 0,
  Saturation = 0
}

 

johnrellis
Legend
August 30, 2022

"Essentially I want to replicate the functionality of what the Reset button does in the Develop module"

 

As you've probably learned by now, your code doesn't do exactly what the Reset button does. If the Raw Defaults for the camera set in Preferences > Presets have non-zero values for some settings, then the Reset button will set those settings back to the non-zero default values, whereas your code sets them to 0.

 

You can get the exact effect of the Reset button using LrDevelopController.resetAllDevelopAdjustments(). To apply that to a batch of photos:

 

1. LrApplicationView.switchToModule ("develop")

 

2. For each photo, do:

catalog:setSelectPhotos (photo, {photo"})

LrDevelopController.resetAllDevelopAdjustments ()

 

There are obscure race conditions in invoking these methods, so you may need to use some judicious calls to LrTasks.sleep().

Photo Taco Podcast
Known Participant
August 25, 2022

It looks like a better way to describe what I want is to replicate what happens when you select all photos and then use the "Reset All" button under Tone Control in the Library module.