Question
Post Process Export Plugin Help Needed
I have been banging my head on this for a good day or so, so looking for some help.
I have a Plugin which I need to do some metadata tweaking when images are exported. The code (see below), sems to work and returns the expected results to the logfile, but the export doesn't continue and no image is exported.
Can anyone see what I am doing wrong or missing ?
Thanks
local LrLogger = import 'LrLogger'
local LrTasks = import 'LrTasks'
local LrApplication = import 'LrApplication'
-- Simple logger initialization for testing
local logger = LrLogger("TestPostProcessActionProvider")
logger:enable("logfile") -- Ensure it logs to Lightroom's log file
logger:info("Plugin has started executing")
return {
sectionForFilterInDialog = function(viewFactory, propertyTable)
return {
title = "Update IPTC:Headline with Title",
}
end,
postProcessRenderedPhotos = function(functionContext, exportContext)
logger:info("Post-process action triggered")
local success, err = LrTasks.pcall(function()
if not exportContext then
logger:error("Export context is invalid or missing.")
return
end
for sourceRendition, renditionToSatisfy in exportContext:renditions() do
LrTasks.startAsyncTask(function()
local photo = renditionToSatisfy.photo
if photo then
local titleValue = photo:getFormattedMetadata("title")
logger:info("Title for photo " .. tostring(renditionToSatisfy.destinationPath) .. ": " .. tostring(titleValue))
if titleValue and titleValue ~= "" then
local status = photo.catalog:withWriteAccessDo( "Set 'Copyright'", function()
photo:setRawMetadata("headline", titleValue)
logger:info("Updated Headline to: " .. titleValue)
end, { timeout=50 } )
logger:info('Headline = ' .. photo:getFormattedMetadata("headline"))
renditionToSatisfy:renditionIsDone(true,"")
else
logger:warn("No titleValue found for photo " .. tostring(renditionToSatisfy.destinationPath))
end
else
logger:warn("No catalog photo found for exported rendition: " .. tostring(renditionToSatisfy.destinationPath))
end
end)
end
logger:info("Processing Complete. Headline has been updated with the titleValue field where applicable.")
end)
-- If an error occurred in the pcall, log it
if success then
else
logger:error("Error in post-process action: " .. tostring(err))
end
end
,
}
