1 Reply Latest reply on Aug 13, 2013 2:48 AM by areohbee

    Export Filter - processing in batches

    BigRedler

      I'm writing an export filter that uses an external tool to process the photos. The tool can/should be multithreaded and I want to take advantage of this by processing the images in groups of 2 or 4 or 8 (or whatever). This means that I gather the paths and the renditions to satisfy in a table and once the table reaches the desired size I process the images in the batch together, empty the table and continue.

       

       

      For some reason I can't make this work. To illustrate, I've reduced this problem to this scenario (Example A)

      1. While iterating filterContext:renditions() I copy the paths and renditionToSatisify to a table

      2. Iterate over the table of copies and process the images one by one.

       

       

      When running this, I'm getting this error:

      This plug-in’s post-processing task did not finish successfully.

      ?:0: attempt to index field 'exportSettings' (a nil value)

       

       

       

       

      It seems to me that LR doesn't like me to call "renditionIsDone" out of sequence but I don't know what to make of this.

       

       

      I'm also adding "Example B" to show that if I call processOne right after adding its entry to the table all is well.

       

       

      Example A

       

       

      function processOne(table)

           local commandResult

           commandResult = PluginManager.doit({table.a})

           if commandResult ~= 0 then

               table.b:renditionIsDone( false, "Image Processing Failed (" ..  commandResult .. ")")

           else

               table.b:renditionIsDone (true,"very good indeed")

           end

      end

       

      function JPEGminiFilterProvider.postProcessRenderedPhotos( functionContext, filterContext )

        local renditionOptions = {

        plugin = _PLUGIN,

        renditionsToSatisfy = filterContext.renditionsToSatisfy,

        filterSettings = function( renditionToSatisfy, exportSettings )

        end,

        }

       

       

        local maxGroupSize = 1

        local groupSize = 0

        local group = {}

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

        local success, pathOrMessage = sourceRendition:waitForRender()

        if success then

        groupSize = groupSize + 1

        group[groupSize]={a=pathOrMessage, b=renditionToSatisfy}

        end

       

        end

       

        for i,v in ipairs(group) do

        processOne(v)

        end

      end

       

       

      Example B

       

       

       

       

      function JPEGminiFilterProvider.postProcessRenderedPhotos( functionContext, filterContext )

           local renditionOptions = {

               plugin = _PLUGIN,

               renditionsToSatisfy = filterContext.renditionsToSatisfy,

               filterSettings = function( renditionToSatisfy, exportSettings )

               end,

           }

       

           local groupSize = 0

           local group = {}

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

               local success, pathOrMessage = sourceRendition:waitForRender()

               if success then

                     groupSize = groupSize + 1

                     group[groupSize]={a=pathOrMessage, b=renditionToSatisfy}

                     processOne(group[groupSize])

               end

           end

      end