2 Replies Latest reply on Apr 10, 2014 5:54 AM by MunkyMorgy

    Overriding image width with updateExportSettings

    MunkyMorgy

      Writing my first lightroom plugin, I have created a minimal example which should set the photo width here and included below. However I can not get the image to be the 400 x 400 specified.

       

      ExportFilterProvider400.lua

      local LrView = import 'LrView'
      local bind   = LrView.bind
      --------------------------------------------------------------------------------
      -- This function will create the section displayed on the export dialog 
      -- when this filter is added to the export session.
      
      local function sectionForFilterInDialog( f, propertyTable )
        return {
          title = LOC "$$$/SDK/MetaExportFilter/SectionTitle=400x400 Filter",
        }
      end
      
      --------------------------------------------------------------------------------
      -- Example on updating export settings
      local function updateExportSettings( exportSettings ) 
        exportSettings.LR_size_maxHeight = 400
        exportSettings.LR_size_maxWidth  = 400
        exportSettings.LR_size_doConstrain = true
      end
      
      --------------------------------------------------------------------------------
      return {
      sectionForFilterInDialog = sectionForFilterInDialog,
      updateExportSettings     = updateExportSettings    , --Does this works
      }
      

       

      Info.lua

       

      return {
        LrSdkVersion        = 3.0,
        LrSdkMinimumVersion = 1.3, -- minimum SDK version required by this plugin
      
        LrPluginName        = "400x400 Export",
        LrToolkitIdentifier = 'sample.export400x400',
      
        LrExportFilterProvider = {
          title = LOC "$$$/SDK/MetaExportFilter/Sample=400x400 Size", -- the string that appears in the export filter section of the export dialog in LR
          file  = 'ExportFilterProvider400.lua', -- name of the file containing the filter definition script
          id    = "metadata1",  -- unique identifier for export filter
        },
      
        VERSION = { major=5, minor=0, revision=0, build=907681, },
      }
      

       

      Adobe Lightroom can load the plugin, and add it to the export session, but the updateExportSettings do not seem to take effect. Tested in Lightroom 5.3.

       

       

      Thanks

        • 1. Re: Overriding image width with updateExportSettings
          areohbee Level 5

          Export service (not export filter) determines the *initial* export settings. They can be overridden by an export filter via the

           

          filterSettings function in the rendition options passed to the renditions iterator, e.g.

           

          local renditionOptions = {

            -- ...

            filterSettings = function( renditionToSatisfy, exportSettings )

                exportSettings.LR_asdf = ... --

            end

          }

           

              for sourceRendition, renditionToSatisfy in filterContext:renditions( renditionOptions ) do
          • 2. Re: Overriding image width with updateExportSettings
            MunkyMorgy Level 1

            Thanks, Will try this out.

             

            On closer reading the SDK Guide on page 51 does mention:

            If the service has defined an updateExportSettings() function, it is called.

            and at the end of that secion:

            The filters, if any, are not involved at this stage.

            Was not aware of the difference of an ExportService plugin and an ExportFilter plugin at the time of reading.

             

            Update:

             

            This is the minimum example I got working Info.lua stays the same:

             

            local function sectionForFilterInDialog( f, propertyTable )

              return {

                title = LOC "$$$/SDK/MetaExportFilter/SectionTitle=400x400 Filter",

              }

            end

             

            --------------------------------------------------------------------------------

            local function postProcessRenderedPhotos( functionContext, filterContext )

             

              local renditionOptions = {

                filterSettings = function( renditionToSatisfy, exportSettings )

                  exportSettings.LR_size_maxHeight = 400

                  exportSettings.LR_size_maxWidth  = 400

                  exportSettings.LR_size_doConstrain = true

                end

              }

             

              for sourceRendition, renditionToSatisfy in filterContext:renditions( renditionOptions ) do

                -- Wait for the upstream task to finish its work on this photo.

                local success, pathOrMessage = sourceRendition:waitForRender()

              end

            end

            --------------------------------------------------------------------------------

             

            return {

              sectionForFilterInDialog  = sectionForFilterInDialog,

              postProcessRenderedPhotos = postProcessRenderedPhotos,

            }