8 Replies Latest reply on Oct 14, 2010 2:50 AM by Trigan

    Problems with applyDevelopPreset in processRenderedPhotos

    L. Hagen

      Hi,

       

      I hope that anybody can help me please. I'm trying to apply a preset to a photo that shall be exported. What I want to do is to set "special" noise and sharpening values for images that shall be published on the web. Therefor the code looks like:

       

       

      function exportServiceProvider.processRenderedPhotos( functionContext, exportContext )

       

      local exportSession = exportContext.exportSession

      -- Make a local reference to the export parameters.
      local nPhotos = exportSession:countRenditions()

      -- Set progress title.
      local progressScope = exportContext:configureProgress{
                  title = nPhotos > 1
                   and LOC( "$$$/desgphoto/Upload/Progress=Uploading ^1 photos to DESGphoto", nPhotos )
                   or LOC "$$$/desgphoto/Upload/Progress/One=Uploading one photo to DESGphoto",
                }


      local propertyTable = {}

      -- check if in Publish Service or not ("not" is the normal export)
      local pubCollection = exportContext.publishedCollection


      -- show the custom export dialog
        local pubCollectionInfoSummary = pubCollection:getCollectionInfoSummary()
        local pubCollectionSettings = pubCollectionInfoSummary.collectionSettings
        propertyTable = pubCollectionSettings

      for photo in exportSession:photosToExport() do     
        debug("apply development setting")

        local LrApplication = import 'LrApplication'
        local catalog = LrApplication.activeCatalog()
        catalog:withWriteAccessDo( 'Importing Images Task', function()
         local settings = photo:getDevelopSettings()

         settings['LuminanceSmoothing'] = propertyTable.luminance_noise
         settings['Sharpness'] = propertyTable.sharpening
         settings['Brightness'] = 100
         
         local preset = LrApplication.addDevelopPresetForPlugin( _PLUGIN, "___Dummy___", settings)
         photo:applyDevelopPreset(preset, _PLUGIN)
        end)

      end


      if propertyTable.action == 'cancel' then return end

      if propertyTable.renderMode == 'skip' then
        for i, rendition in exportSession:renditions() do
         rendition:skipRender()
        end
      end


      -- gather returned values done in the custom dialog
      ...


      -- Iterate through photo renditions.
      for i, rendition in exportContext:renditions{ stopIfCanceled = true } do

        local photo = rendition.photo
        local photoname = photo:getFormattedMetadata('fileName')
        local result = {}
       
        info('Getting next photo...' .. photoname)

        if not rendition.wasSkipped then
        
         -- render photo
         local success, pathOrMessage = rendition:waitForRender()
         -- Check for cancellation again after photo has been rendered.
         if progressScope:isCanceled() then break end

           upload the photo

       

        

       

      My problem is now that the preset is beeing applied to the image. This seems to work because I can see the final result in LR3.2RC. But the image that is beeing exported is just before the settings were applied. So is there something I did wrong? Where is the mistake?

       

      Please help.

       

      Thanks,

      Lars