Lightroom 5 SDK: photo:requestJpegThumbnail makes for wonky-colored previews.

  • 1
  • Problem
  • Updated 5 years ago
If one uses photo:requestJpegThumbnail in a plugin (and a fresh preview is not already available), the color of the (newly created) image that is returned is off, and the color of the library preview in Lightroom proper will have the same off color, unless one selects the photo in the develop module or some such thing to get Lr proper to refresh preview. It's as if:

* photo:requestJpegThumbnail will create preview if not already available, but does it wrongly.
* And that same wrongly created thumbnail will be returned to the plugin, as well as Lightroom proper, until Lr re-renders it correctly.

I'm guessing the icc profile is getting mis-handled when preview-generation is plugin-initiated, but not when generated in Lr natively.

PS - I'm aware the Lr5 SDK is not yet released, but hopefully this will either be fixed or documentation will explain how to do it right, prior to SDK release.

Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 388 Reply Likes

Posted 6 years ago

  • 1
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 388 Reply Likes
Did some more testing.. - on my Windows 7 box, problem is reproducible in Lr5.6 thusly:

1. Go into grid mode of library module.
2. execute some code like this, in a task - e.g. put it in a script, or plugin, and make it work..

local photo = catalog:getTargetPhoto()
local dim = photo:getRawMetadata( 'croppedDimensions' )
assert( dim.width, "no width" )
local dat, err
local set = { Exposure2012=photo:getDevelopSettings().Exposure2012+.3 }
local pset = LrApplication.addDevelopPresetForPlugin( _PLUGIN, "Incr Exp'12", set )
assert( pset, "no pset" )
local status = catalog:withWriteAccessDo( "", function()
photo:applyDevelopPreset( pset, pluginObject )
end, { timeout=10 } )
assert( status=='executed', "no exec" )
local holdRefObj = photo:requestJpegThumbnail( dim.width, dim.height, function( one, two )
dat, err = one, two
end )
local cnt = 1000
while dat == nil and err == nil and cnt > 0 do
LrTasks.sleep( .2 )
cnt = cnt - 1
holdRefObj = nil
debugPause( dat ~= nil and #dat or "no dat", err, 1000-cnt ) -- however you do this sorta thing.. - make sure 1000-cnt is > 1. this should take at least a second or two or the experiment failed.

3. Zoom to 1:1 (watch color change slightly, wrongly, if you can notice it). If your standard previews aren't too big relative to full-size photo dimensions, you can start in loupe view instead of grid view and the color shift is easier to see.
4. Click quick-dev exposure single left arrow (watch color change back to what it should be - more noticeable when zoomed).

Note: this can be done using any adjustment, I picked exposure arbitrarily. Make sure you put your photo back how it was when finished testing.

The problem happens every time for me.

To be clear: the color shift is subtle, but noticeable, and wrong, and permanent until Lr itself rebuilds the preview e.g. due to a develop setting change.