Skip to main content
Known Participant
Jan 3, 2024 1:25 PM UTC
Needs More Info

P: photo:getDevelopSettings() does not always return all / valid values

After applying Develop Settings (either via SDK or via UI), sometimes photos are left in a state where photo:getDevelopSettings() will not give correct values for all sliders, especially Temperature and Tint. (and also the visual representation in the grid does not seem to be updated - when you scroll to the image, you see it visually update only after it has entered the viewport).

 

Simple code snippet to try for yourself:

 

 

local LrApplication = import "LrApplication"
local LrTasks = import "LrTasks"
local LrDialogs = import "LrDialogs"
local LrFunctionContext = import "LrFunctionContext"

LrTasks.startAsyncTask(function()

    local catalog = LrApplication.activeCatalog()
    local photos = catalog:getTargetPhotos()
    local badSettings = {}

    for i, photo in ipairs(photos) do
        local settings = photo:getDevelopSettings()

        local temperature = nil
        local tint = nil

        if settings.IncrementalTemperature ~= nil and settings.IncrementalTint ~= nil then
            temperature = settings.IncrementalTemperature
            tint = settings.IncrementalTint

            if temperature < -100 or temperature > 100 or tint < -100 or tint > 100 then
                badSettings[#badSettings + 1] = {photo,
                                                 "OUT OF RANGE incTemp: " .. tostring(temperature) .. " incTint: " ..
                    tostring(tint)}
            end
        elseif settings.Temperature ~= nil and settings.Tint ~= nil then
            temperature = settings.Temperature
            tint = settings.Tint

            if temperature < 2000 or temperature > 50000 or tint < -150 or tint > 150 then
                badSettings[#badSettings + 1] = {photo,
                                                 "OUT OF RANGE temp: " .. tostring(temperature) .. " tint: " ..
                    tostring(tint)}
            end
        else
            badSettings[#badSettings + 1] = {photo,
                                             "NIL temp: " .. tostring(settings.Temperature) .. " tint: " ..
                tostring(settings.Tint) .. " incTemp: " .. tostring(settings.IncrementalTemperature) .. " incTint: " ..
                tostring(settings.IncrementalTint)}
        end
    end

    if #badSettings > 0 then
        LrFunctionContext.callWithContext("CheckForBadSettings", function(context)

            local info = ""
            for i, b in ipairs(badSettings) do
                local photo = b[1]
                local reason = b[2]

                info = info .. photo:getFormattedMetadata("fileName") .. ":" .. tostring(reason) .. ", \n"
            end

            local result = LrDialogs.message("Found " .. tostring(#badSettings) .. " / " .. tostring(#photos) ..
                                                 " images bad settings", info)
        end)
    else
        LrDialogs.message("No bad settings found")
    end

end)

 

 

 

How to reproduce:

Take a catalog with multiple photos. Select more than are visible in the grid viewport (in my example i select 102 images, when the grid only shows 9). Do right click -> develop settings -> reset develop settings (or set them via photo:applyDevelopSettings()).

With the images still selected, run above code. We quite consistently get:

Found 73 / 102 images bad settings (basically all the photos outside the viewport)

If i scroll through the grid down a few images, i see them visually update and when running the code again, the number of bad images reduces by the number of images i had scrolled through.

 

Note: Instead of nil values we also encountered -999999 values in some cases.

 

Is this known/intented, and is there a way to trigger LrC to update the images via SDK? We tried photo:

requestJpegThumbnail() but this also did not consistently ensure good values.

11 replies

johnrellis
Legend
Feb 28, 2025 4:32 AM UTC

I forgot to mention that this workaround is slow -- about 0.25 seconds per photo on my computer.

Translate
johnrellis
Legend
Feb 27, 2025 7:00 PM UTC

@LightroomStatistics, recently while learning how LR builds previews, I discovered a workaround for this bug: Increment the photo's exposure by 0.01, request the photo's thumbnail, decrement the exposure by 0.01, request the thumbnail again. After doing this, the value of Temperature will be non-nil.   Here's a script demonstrating the workaround:

local catalog = import "LrApplication".activeCatalog ()
local currentTime = import "LrDate".currentTime
local message = import "LrDialogs".message
local sleep = import "LrTasks".sleep

local size = 50
local poke   

local function fix (photo)
    poke (photo, 0.01)
    poke (photo, -0.01)
    return photo:getDevelopSettings ().Temperature
    end

function poke (photo, delta)
    local exp = photo:getDevelopSettings ().Exposure2012
    catalog:withWriteAccessDo ("Poke " .. delta, function ()
        photo:applyDevelopSettings {Exposure2012 = exp + delta}
        end, {timeout = 30})

    local done = false
    local handle = photo:requestJpegThumbnail (size, size, function (data, err)
        if err then assert (err) end 
        done = true  
        end)

    while not done do sleep (0.05) end 
    end

local t = currentTime ()
local nNil, nFixed = 0, 0  
for _, photo in ipairs (catalog:getMultipleSelectedOrAllPhotos ()) do 
    if not photo:getDevelopSettings ().Temperature then
        nNil = nNil + 1
        if fix (photo) then nFixed = nFixed + 1 end 
        end
    end
t = currentTime () - t
message ("Test results", 
    string.format ("size: %d, nil: %d, fixed: %d, time/photo: %f",
        size, nNil, nFixed, t / nNil))
Translate
Inspiring
Feb 26, 2025 8:06 AM UTC

Any news on this?

@Rikk Flohr: Photography

Translate
johnrellis
Legend
Jun 14, 2024 4:10 PM UTC

The only workaround I know of is to do Library > Previews > Build Standard-Sized Previews, which forces the deferred rendering of photos with changed settings. The SDK doesn't provide any methods for doing this, unfortunately.

Translate
Inspiring
Jun 14, 2024 10:37 AM UTC

Also experiencing this behavior. Any workaround to get the correct values.
I need them for Temperature and Tint.

 

Also noticed that after Resetting the settings with <Ctrl><Shift> R a lot images report no values for Temperature and Tint.

 

Not getting the develop settings break many of the existing plug-ins!
This is a core functioanlity of the SDK

Translate
Inspiring
Jun 14, 2024 9:18 AM UTC

Lightroom version 13.3.1 and CameraRaw 16.3.1

 

After setting the White balance to "As shot" the photo:getDevelopSettings() doesn't return the correct develop settings for Temperature or Tint. All photos selected are RAW files.

 

Also there is a difference in behavior when running the script on images with or without having resetted the settings to original <Ctrl><Shift> R.

On new images the value of -999999 returned, however when you Reset the images with <Ctrl><Shift> R and run the script again, instead of the value for Temperature and Tint is nil.

 

Only after 1 or more seconds the correct values are returned.

 

First run on new images:

 

Now hitting the Reset settings <Ctrl><Shift> R key:
Same images still selected.

Code used:

 

local LrApplication = import("LrApplication")
local LrDialogs = import("LrDialogs")
local LrFunctionContext = import("LrFunctionContext")

local catalog = LrApplication.activeCatalog()

local logFilename = 'WhiteBalance_01.txt'
local MyLogger = import 'LrLogger' (logFilename)
MyLogger:enable("logfile")

local inspect = require "inspect"

local function main(context)
	LrDialogs.attachErrorDialogToFunctionContext(context)

	local photos = catalog:getTargetPhotos()
	MyLogger:info("#photos", #photos)

	local devSettings = { WhiteBalance = "As shot" }
	catalog:withWriteAccessDo("Apply White balance settings", function()
		local preset = LrApplication.addDevelopPresetForPlugin(_PLUGIN, "WB As Shot", devSettings)

		for _, photo in ipairs(photos) do
			MyLogger:info(photo:getFormattedMetadata("fileName"))
			photo:applyDevelopPreset(preset, _PLUGIN)
		end
	end)

	local message = "Loop 1\n"
	local nilValues = true
	local counter = 1
	while nilValues and (counter < 20) do
		nilValues = false

		for _, photo in ipairs(photos) do
			local fileName = photo:getFormattedMetadata("fileName")
			local developSetings = photo:getDevelopSettings()
			MyLogger:info(fileName, inspect(developSetings))

			-- Test for nil values
			if (nilValues == false) and
				(
					(developSetings.Temperature == nil) or
					(developSetings.Temperature == -999999) or
					(developSetings.Tint == nil) or
					(developSetings.Tint == -999999)
				) then
				nilValues = true
			end

			message = message ..
				string.format("image: %-15s temperature: %-8s tint: %-8s\n", fileName,
					developSetings.Temperature or "nil",
					developSetings.Tint or "nil")
		end

		if (nilValues == true) then
			counter = counter + 1
			LrTasks.sleep(0.5)

			message = message .. string.format("\n\nLoop %d -- wait for an extra %.1f seconds\n",counter, 0.5)
		end
	end

	LrDialogs.message("LightroomStatistics", message)
end

LrFunctionContext.postAsyncTaskWithContext("", main)

 

 

Translate
Inspiring
Feb 26, 2025 8:06 AM UTC

Any news on this?

@Rikk Flohr: Photography

Translate
Rikk Flohr-Retired
Adobe Employee
Jan 4, 2024 2:43 PM UTC

Added ticket - updated status

Translate
Rikk Flohr: Adobe Photography Org
johnrellis
Legend
Jan 4, 2024 2:14 AM UTC

[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]

 

I had filed a bug report about this for LR 12.2, but my bug recipe worked correctly in LR 13.0.1, so I asked Adobe to close the bug report:

https://community.adobe.com/t5/lightroom-classic-discussions/photo-getdevelopsettings-does-not-always-return-all-valid-values/td-p/14331997 

 

However, following your steps, I can reproduce the problem in LR 13.1 / Mac OS:

 

1. Put 200 raws in the Quick Collection and select it as the current source.

 

2. Select all the photos and do Quick Develop > Reset All.

 

3. Run your script above and observe these incorrect results:

 

4. Run the Any Filter plugin's Filter command with the single criterion Temperature and observe the same number of photos (183) with no value for Temperature:

 

5. Select all the photos and do Library > Previews > Build Standard-Sized Previews, forcing LR to re-render all the images.

 

6. Rerun the script and Any Filter and observe all photos have valid values for Temperature.

-------

 

There have been a number of similar bugs reported over the years. Internally, LR defers a lot of computation after the user applies a command to a batch of photos, and the SDK doesn't always force deferred computation when accessing develop settings.  Sometimes there are bugs with the deferred computation overwriting user-applied settings, with no plugins involved (e.g. applying Auto Settings to a batch of photos).

Translate
johnrellis
Legend
Jan 4, 2024 2:16 AM UTC

@Rikk Flohr: Photography, please consider moving to Bugs. (See my bug recipe above.)

Translate