--[[ Calculate average noise reduction and sharpening by ISO SETUP INSTRUCTIONS Temporarily save this file onto your desktop and call it "YOURFILENAME.lua". Now you need to create a scripts folder: In Lightroom, choose Lightroom > Preferences (Mac OS) or Edit > Preferences (Windows). Choose the Preset tab and select Show Lightroom Presets folder. Create a folder in the Lightroom folder called Scripts. Copy the "YOURFILENAME.lua" script into the Scripts folder. Quit and reopen Lightroom. You should now see a little scripts menu to the right of the Help menu. It has a single item Title case keywords. --]] LrView = import 'LrView' LrDialogs = import 'LrDialogs' LrApplication = import 'LrApplication' catalog = LrApplication.activeCatalog() LrTasks = import 'LrTasks' LrDate = import 'LrDate' LrPathUtils = import 'LrPathUtils' LrFunctionContext = import 'LrFunctionContext' ProgressScope = import 'LrProgressScope' function writeXMP(txt) local myTime = LrDate.currentTime() myDate = LrDate.timeToUserFormat( myTime , "%Y-%m-%d %H%M%S", false) logPath = LrPathUtils.getStandardFilePath('desktop') fileName = "ISO Dependent " .. myDate .. ".txt" if MAC_ENV then logPath = logPath .. "/" else logPath = logPath .. "\\" end Hnd = io.open(logPath .. fileName , "w") txt = string.gsub(txt , '-m"', '-m -V -k' ) Hnd:write (txt) Hnd:close () Hnd = nil LrDialogs.showBezel( fileName .. " written to desktop", 5 ) end function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end if LrApplication.versionTable()['major'] <9 then LrDialogs.message( "Oops - must be run in Lr9 or later" ) else LrTasks.startAsyncTask( function() local ProgressScope = ProgressScope({ title = "Average sharpening and noise reduction", caption = '', }) local cat_photos = catalog:getTargetPhotos() local isoValues = {} local sharps = {"Sharpness", "SharpenRadius", "SharpenDetail", "SharpenEdgeMasking", "LuminanceSmoothing"} photos = {} for i, photo in ipairs(cat_photos) do iso = photo:getRawMetadata( "isoSpeedRating" ) if iso ~= nil then table.insert(photos,photo) end end --create an variable for each iso, with properties for photos and each of the sharpness values for i, photo in ipairs(photos) do iso = photo:getRawMetadata( "isoSpeedRating" ) dev = photo:getDevelopSettings() if isoValues[iso] == nil then isoValues[iso] = {} isoValues[iso]["photos"] = {} for z= 1, #sharps do isoValues[iso][(sharps[z])] = 0 end end table.insert( isoValues[iso]["photos"] , photo) for z= 1, #sharps do isoValues[iso][(sharps[z])] = isoValues[iso][(sharps[z])] + dev[(sharps[z])] end fileName = photo:getFormattedMetadata('fileName') ProgressScope:setCaption("Item : " .. i .. ' File name: ' .. fileName) ProgressScope:setPortionComplete( i, #photos ) end -- sort the ISOs into a new table a = {} for n in pairs(isoValues) do table.insert(a, n) end table.sort(a) -- create the xmp lines local str = {} table.insert(str, "" ) table.insert(str, " " .. "" ) for i,n in ipairs(a) do isoValue = isoValues[n] table.insert(str, " " .. '' end table.insert(str, " " .. "") table.insert(str, "") writeXMP(table.concat(str,"\n")) ProgressScope:done() end) end