Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
4

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

Explorer ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

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.
Bug Investigating
TOPICS
SDK

Views

378
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Pinned Reply

Adobe Employee , Jan 04, 2024 Jan 04, 2024

Added ticket - updated status

Status Investigating

Votes

Translate
11 Comments
LEGEND ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

[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-alway... 

 

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:

johnrellis_0-1704331971675.pngexpand image

 

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:

 

johnrellis_2-1704332069827.pngexpand image

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).

Votes

Translate

Report

Report
LEGEND ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Adobe Employee ,
Jan 04, 2024 Jan 04, 2024

Copy link to clipboard

Copied

Added ticket - updated status

Rikk Flohr: Adobe Photography Org
Status Investigating

Votes

Translate

Report

Report
Participant ,
Jun 14, 2024 Jun 14, 2024

Copy link to clipboard

Copied

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:

LightroomStatistics_0-1718356344460.pngexpand image

 

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

LightroomStatistics_1-1718356409391.pngexpand image

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)

 

 

Votes

Translate

Report

Report
Participant ,
Jun 14, 2024 Jun 14, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
LEGEND ,
Jun 14, 2024 Jun 14, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Participant ,
Feb 26, 2025 Feb 26, 2025

Copy link to clipboard

Copied

Any news on this?

@Rikk Flohr: Photography

Votes

Translate

Report

Report
Participant ,
Feb 26, 2025 Feb 26, 2025

Copy link to clipboard

Copied

Any news on this?

@Rikk Flohr: Photography

Votes

Translate

Report

Report
LEGEND ,
Feb 27, 2025 Feb 27, 2025

Copy link to clipboard

Copied

@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))

Votes

Translate

Report

Report
LEGEND ,
Feb 27, 2025 Feb 27, 2025

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
LEGEND ,
Feb 27, 2025 Feb 27, 2025

Copy link to clipboard

Copied

LATEST

Votes

Translate

Report

Report