local LrApplication = import "LrApplication" local LrDialogs = import "LrDialogs" local LrExportSession = import "LrExportSession" local LrPathUtils = import "LrPathUtils" local LrProgressScope = import "LrProgressScope" local LrTasks = import "LrTasks" local catalog = LrApplication.activeCatalog () local photo = catalog:getTargetPhoto () local settings = { LR_DNG_compatibility = 117506048, LR_DNG_compressed = true, LR_DNG_conversionMethod = "preserveRAW", LR_DNG_embedCache = true, LR_DNG_embedRAW = false, LR_DNG_lossyCompression = true, LR_DNG_previewSize = "none", LR_embeddedMetadataOption = "all", LR_exportServiceProvider = "com.adobe.ag.export.file", LR_renamingTokensOn = true, LR_tokenCustomString = "", LR_tokens = "medium-lossless", LR_format = "DNG"} settings.LR_export_destinationPathPrefix = LrPathUtils.getStandardFilePath "desktop" LrTasks.startAsyncTask (function () for _, size in ipairs {"medium", "large"} do for _, compression in ipairs {false, true} do settings.LR_DNG_previewSize = size settings.LR_DNG_lossyCompression = compression settings.LR_tokens = tostring (settings.LR_DNG_lossyCompression) .. "-" .. settings.LR_DNG_previewSize local session = LrExportSession {photosToExport = {photo}, exportSettings = settings} session:doExportOnNewTask () LrTasks.sleep (0.001) --[[ If we don't sleep here, presumably to give the new export task a chance to get started, we get "An internal error has occurred. AgExportSession: startRendering: can not call twice on the same session." Yet another LR race condition. ]] local scope = LrProgressScope {title = "Export " .. LrPathUtils.leafName (photo.path)} local renditions = session:renditions {progressScope = scope, renderProgressPortion = 1, stopIfCanceled = true} for _, rendition in renditions do local success, err = rendition:waitForRender () LrDialogs.message ("waitForRender: " .. tostring (success) .. " " .. err) end scope:done () end end end)