3 Replies Latest reply on Oct 10, 2013 7:04 AM by c.pfaffenbichler

    How to batch automate overlay of stacks?

    LindaF

      I am very new to photoshop, and with the need to automate a very time consuming work process.

       

      As things are now, I manually open a batch of photos (a minimum of 2, could be 3 or 4), copy-paste them on each other, create layers and color them so that each photo get an individual color, and then save it as one merged image.

       

      As an example: http://www.activemotif.com/catalog/623/chromeo-red-fluorescent-fixed-cell-staining-kit

       

      Initially each batch of photos are located in the same folder, and all folders with a batch, are located in a shared folder, but I would happily change this manually if it is needed for an automated batch process.

       

      I would like all the merged photos from the different batches, to be saved in one folder.

       

      If possible... It would be more than awesome at the same time to save the individual photos with their individual applied colors in a different folder too.

       

       

      I now am able to apply an action at a stack that color it as I like..

      I am also able to open the batch files manually and apply an action which generates a colored overlay..

      But how to open a batch a photos, apply a functional action and then save automatically - I can not!

       

      Hope for your help. Thank you!

        • 1. Re: How to batch automate overlay of stacks?
          c.pfaffenbichler Level 9

          You may want to try

          http://forums.adobe.com/community/photoshop/photoshop_scripting?view=discussions

           

          But please provide more information.

          What are the naming conventions? Can the images that belong together be identified unmistakeably?

          What are the coloring requirements?

          Can you provide the original files and the resulting file for one example?

           

          I manually open a batch of photos (a minimum of 2, could be 3 or 4), copy-paste them on each other,

          This could also be achieved via File > Scripts > Load Files into Stack

          • 2. Re: How to batch automate overlay of stacks?
            LindaF Level 1

            The photos are from a Zeiss software processing the inputs from the microscope at which the photos are taken. Each batch are a set og photos taken at the same object, but thorugh different light channels, why the part of the object which is photographed differs, e.g. one photo shows the cell nuclei, one photo showing the cell surface...

             

            All photos within a batch are named as follows:

            Snap-1490_b0c0x0-1388y0-1040.tif

            and

            Snap-1490_b0c1x0-1388y0-1040.tif

             

            while the next batch will be named

            Snap-1491_b0c0x0-1388y0-1040.tif

            and

            Snap-1491_b0c1x0-1388y0-1040

             

            In every batch the photos thermed 0 (marked in bold) are to be blue, and the one termed 1 (marked in bold) are to be green. And all the photos are located in one folder, but with the photos for each batch being located in its own subfolder (e.g. all 1490 photos in one subfolder, all 1491 photos in an other subfolder etc).

             

            I was not able to upload the photos (content was not allowed?), but should be available from this dropbox link:

            https://www.dropbox.com/sh/exrj3fnyugudtum/wlP0brwbVl

            Note: the photos look different in the dropbhox folder, but when downloaded and opened in photoshop they look fine.

             

            For the coloring details, I think these photos should tell it.

             

            I really appreciate your help.

            • 3. Re: How to batch automate overlay of stacks?
              c.pfaffenbichler Level 9

              Could you try this (select the folder containing the folders containing the 1490 and 1491 images):

              // merge images in folders;

              // 2013, use it at your own risk;

              #target photoshop

              // dialog for folder-selection;

              var theFolder = Folder.selectDialog ("select folder");

              if (theFolder) {

              var theFolders = theFolder.getFiles(getFolder);

              // create the psd-options;

              psdOpts = new PhotoshopSaveOptions();

              psdOpts.embedColorProfile = true;

              psdOpts.alphaChannels = false;

              psdOpts.layers = true;

              psdOpts.spotColors = true;

              // work through folders;

              for (var m = 0; m < theFolders.length; m++) {

                        var theFiles = theFolders[m].getFiles(getSomeFiles);

              // run through the files;

                        for (var a  = 0; a < theFiles.length; a++) {

                                  var thisFile = theFiles[a];

                                  if (thisFile.name.indexOf("1490") != -1) {

              // open background-image;

                                            var theFile = app.open(File(thisFile.fullName));

                                            theFile.activeLayer = theFile.layers[0];

                                            theFile.layers[0].isBackgroundLayer = false;

                                            showOneChannel ("Bl  ");

              // place foreground-image;

                                            var theOtherFile = String(thisFile.fullName).replace("1490", "1491");

                                            if (File(theOtherFile).exists == true) {

                                                      var theFile2 = app.open(File(theOtherFile));

                                                      var theAddedLayer = theFile2.layers[0].duplicate(theFile, ElementPlacement.PLACEATBEGINNING);

              // close second file;

                                                      theFile2.close();

                                                      showOneChannel ("Grn ");

                                                      };

              // save the combined files;

                                            theFile.saveAs(new File (theFolders[m] +"/"+ thisFile.name.replace(".tif", ".psd")), psdOpts);

                                            theFile.close(SaveOptions.DONOTSAVECHANGES)

                                            }

                                  }

                        }

              };

              ////////////////////////////////////

              ////// buffer number with zeros //////

              function bufferNumberWithZeros (number, places) {

                        var theNumberString = String(number);

                        for (var o = 0; o < (places - String(number).length); o++) {

                                  theNumberString = String("0" + theNumberString)

                                  };

                        return theNumberString

                        };

              ////// get psds, tifs and jpgs from files //////

              function getFolder (theFile) {

                  if (theFile instanceof Folder) {

                      return true

                      };

                        };

              ////// get psds, tifs and jpgs from files //////

              function getSomeFiles (theFile) {

                  if (theFile.name.match(/\.(jpg|tif|psd|pdf|)$/i)) {

                      return true

                      };

                        };

              ////// red "Rd  ", green ,"Grn " blue "Bl  " //////

              function showOneChannel (theChannel) {

              // =======================================================

              var idsetd = charIDToTypeID( "setd" );

                  var desc5 = new ActionDescriptor();

                  var idnull = charIDToTypeID( "null" );

                      var ref2 = new ActionReference();

                      var idLyr = charIDToTypeID( "Lyr " );

                      var idOrdn = charIDToTypeID( "Ordn" );

                      var idTrgt = charIDToTypeID( "Trgt" );

                      ref2.putEnumerated( idLyr, idOrdn, idTrgt );

                  desc5.putReference( idnull, ref2 );

                  var idT = charIDToTypeID( "T   " );

                      var desc6 = new ActionDescriptor();

                      var idchannelRestrictions = stringIDToTypeID( "channelRestrictions" );

                          var list1 = new ActionList();

                          var idChnl = charIDToTypeID( "Chnl" );

                          var idBl = charIDToTypeID( theChannel );

                          list1.putEnumerated( idChnl, idBl );

                      desc6.putList( idchannelRestrictions, list1 );

                      var idLefx = charIDToTypeID( "Lefx" );

                          var desc7 = new ActionDescriptor();

                          var idScl = charIDToTypeID( "Scl " );

                          var idPrc = charIDToTypeID( "#Prc" );

                          desc7.putUnitDouble( idScl, idPrc, 416.666667 );

                      var idLefx = charIDToTypeID( "Lefx" );

                      desc6.putObject( idLefx, idLefx, desc7 );

                  var idLyr = charIDToTypeID( "Lyr " );

                  desc5.putObject( idT, idLyr, desc6 );

              executeAction( idsetd, desc5, DialogModes.NO );

              };

              //////

              function placeFile (thePath) {

                        alert (thePath);

              // =======================================================

              var idPlc = charIDToTypeID( "Plc " );

                  var desc14 = new ActionDescriptor();

                  var idnull = charIDToTypeID( "null" );

                  desc14.putPath( idnull, new File( thePath ) );

                  var idFTcs = charIDToTypeID( "FTcs" );

                  var idQCSt = charIDToTypeID( "QCSt" );

                  var idQcsa = charIDToTypeID( "Qcsa" );

                  desc14.putEnumerated( idFTcs, idQCSt, idQcsa );

                  var idOfst = charIDToTypeID( "Ofst" );

                      var desc15 = new ActionDescriptor();

                      var idHrzn = charIDToTypeID( "Hrzn" );

                      var idPxl = charIDToTypeID( "#Pxl" );

                      desc15.putUnitDouble( idHrzn, idPxl, 0.000000 );

                      var idVrtc = charIDToTypeID( "Vrtc" );

                      var idPxl = charIDToTypeID( "#Pxl" );

                      desc15.putUnitDouble( idVrtc, idPxl, 0.000000 );

                  var idOfst = charIDToTypeID( "Ofst" );

                  desc14.putObject( idOfst, idOfst, desc15 );

                  var idWdth = charIDToTypeID( "Wdth" );

                  var idPrc = charIDToTypeID( "#Prc" );

                  desc14.putUnitDouble( idWdth, idPrc, 100 );

                  var idLnkd = charIDToTypeID( "Lnkd" );

                  desc14.putBoolean( idLnkd, true );

              executeAction( idPlc, desc14, DialogModes.NO );

              };