1 Reply Latest reply on Sep 14, 2015 6:00 AM by Chuck Uebele

    Batch median script

    MassFXMedia

      I'm working on a timelapse project where I'm combining multiple frames shot on each day into one stacked median frame. The final timelapse will be a sequence of these median images. I'm trying to piece together a script that will allow me to process a master folder that contains sub-folders from each day's images and then output a median image for each day (named the same as the sub-folder). I'm having trouble picking through the default statistics script and feeding it a source folder containing sub-folders to iterate through.

       

      This is how I'm building my folder structure:

      Timelapse main folder

           Day 1 (12 images to median)

           Day 2 (12 images to median)

           ...

           Median Output (median frame from each day)

       

      I really appreciate this community and your help!

        • 1. Re: Batch median script
          Chuck Uebele Adobe Community Professional & MVP

          Rather than try to mess with the statistics script, why don't you create your own. You would just need a script that looped through the folders you wanted, put all the files in one day's folder into an array that then could open each file and duplicate it into the master folder. Then using scriptlistener, select all the layers, create a smart object, and apply mean:

           

          #target photoshop
          // =======================================================
          var idselectAllLayers = stringIDToTypeID( "selectAllLayers" );
              var desc15 = new ActionDescriptor();
              var idnull = charIDToTypeID( "null" );
                  var ref6 = new ActionReference();
                  var idLyr = charIDToTypeID( "Lyr " );
                  var idOrdn = charIDToTypeID( "Ordn" );
                  var idTrgt = charIDToTypeID( "Trgt" );
                  ref6.putEnumerated( idLyr, idOrdn, idTrgt );
              desc15.putReference( idnull, ref6 );
          executeAction( idselectAllLayers, desc15, DialogModes.NO );
          
          // =======================================================
          var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );
          executeAction( idnewPlacedLayer, undefined, DialogModes.NO );
          
          // =======================================================
          var idapplyImageStackPluginRenderer = stringIDToTypeID( "applyImageStackPluginRenderer" );
              var desc16 = new ActionDescriptor();
              var idimageStackPlugin = stringIDToTypeID( "imageStackPlugin" );
              var idavrg = charIDToTypeID( "avrg" );
              desc16.putClass( idimageStackPlugin, idavrg );
              var idNm = charIDToTypeID( "Nm  " );
              desc16.putString( idNm, """Mean""" );
          executeAction( idapplyImageStackPluginRenderer, desc16, DialogModes.NO );