SDK: photo:requestJpegThumbnail generates an invalid file (Windows)
Hello,
I need to export thumbnails of photos I've selected with the photo:requestJpegThumbnail method. While it works great on MacOS, on Windows the exported image is not valid (no preview + error while opening the file):

Tested on:
- Mac OS 13.0.1 + Lr Classic 12.1 & 12.2: works well
- Windows 10 21H1 + Lr Classic 12.1 & 12.2 : FAIL
Steps to reproduce:
- Create a c:/temp folder (or change the hardcoded export folder in the source code)
- Install the plugin in Lr
- Select at least one photo to export in the Library module
- Select Library > Plug-in extras > Test export thumbnails
- Check the file(s) in the c:/temp folder
The plugin can be downloaded here: https://pierrepichot.com/wp-content/uploads/2023/02/test.lrdevplugin.zip
The code is the following:
local LrTasks = import 'LrTasks'
local LrApplication = import 'LrApplication'
local catalog = LrApplication.activeCatalog()
LrTasks.startAsyncTask(function()
LrTasks.startAsyncTask(function()
local selectedPhotos = catalog.targetPhotos
for _, photo in ipairs( selectedPhotos ) do
local uuid = photo:getRawMetadata("uuid")
local previewname = uuid .. ".jpg"
local folder = "c:\\temp\\"
--local folder = "/Users/Me/Documents/"
local holdRefObj = photo:requestJpegThumbnail(1600, 1000, function( success, failure )
local f = io.open(folder .. previewname,"w")
f:write(success)
f:close()
end )
LrTasks.sleep(.5)
end
end )
end )
Thanks!
