5 Replies Latest reply on Dec 3, 2012 1:47 AM by Paul Riggott

    Combining two images like picture package and run it for all the images inside a folder

    nesselkus Level 1

      I have hundreds of jpg photo files in a folder. I  want to resize and combine 2 4.5x6 jpg files into one 4x6 jpg file  containing 2 photos, each 3x4. Then I can upload them and get them  printed by a photo printing service. I can do this by picture package but it takes hours and hours to do it for every couple of image inside a folder. I need to browse for the folder and then the script shall combine every 2 images repeatingly. So if I have 500 images the combined images number shall be 250 totally at the end.

      Do you have any other suggestions? Thanks!

        • 1. Re: Combining two images like picture package and run it for all the images inside a folder
          JJMack Most Valuable Participant

          I think you want to look at contact sheet rather them picture package.  Your images have a pixel size that has a 3:4 Aspect Ratio without cropping they can be printed at any 3:4 aspect ratio size 3x4, 6x8, 4.5x6 just by changing the images print DPI resolution. Pictute Package is used to print several prints of an image as a package containg sever copies of a single image at one or more sizes on a sheet of paper.  Where contact sheet is set up to create image sheets for all images in a folder. If you do not care which two pictures print on a sheet. Try running a contact sheet script for 4x6 sheets that have 2 3x4 images.

           

          Print programs like qimage can also be used to do that job.

          • 2. Re: Combining two images like picture package and run it for all the images inside a folder
            Paul Riggott Level 6

            This should do the job....

             

            #target photoshop
            main();
            function main(){
            var inputFolder = Folder.selectDialog("Please select the folder with Files to process"); 
            if(inputFolder == null) return;
            var startRulerUnits = preferences.rulerUnits;
            app.displayDialogs = DialogModes.NO;
            var outputFolder = Folder(inputFolder + "/Combined");
            if(!outputFolder.exists) outputFolder.create();
            var fileList = inputFolder.getFiles(/.jpg$/i); 
            while(fileList.length>0){
            preferences.rulerUnits = Units.PIXELS;
            if(fileList.length==1) break;
            var mainDoc = open(fileList.shift());
            mainDoc.resizeCanvas((mainDoc.width*2), mainDoc.height, AnchorPosition.TOPLEFT);
            var tmp = open(fileList.shift());
            tmp.activeLayer.duplicate(mainDoc); 
            tmp.close(SaveOptions.DONOTSAVECHANGES);
            var LB = mainDoc.activeLayer.bounds;
            mainDoc.activeLayer.translate((mainDoc.width-LB[2].value),0);
            mainDoc.flatten();
            preferences.rulerUnits = Units.PERCENT;
            mainDoc.resizeImage(66.66666, undefined, undefined, ResampleMethod.BICUBICSHARPER);
            var saveFile = File(outputFolder + "/" + decodeURI(activeDocument.name));
            SaveJPEG(saveFile, 10);
            mainDoc.close(SaveOptions.DONOTSAVECHANGES);
            }
            preferences.rulerUnits = startRulerUnits;
            }
            function SaveJPEG(saveFile, jpegQuality){
            jpgSaveOptions = new JPEGSaveOptions();
            jpgSaveOptions.embedColorProfile = true;
            jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
            jpgSaveOptions.matte = MatteType.NONE;
            jpgSaveOptions.quality = jpegQuality; 
            activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
            }
            
            • 3. Re: Combining two images like picture package and run it for all the images inside a folder
              JJMack Most Valuable Participant

              Paul's scritp will work if all images are 4.5x6 Portraits and the script will save files. Where menu File>Automate>Contact Sheet II will leave all sheets open in Photoshop you will need to save them. However as long as the images were shot with a 3:4 Aspect ratio camera it make no difference  what their Print DPI resolution is set to or if they are Landscape or Portrait Contact Sheet II has options to handle it.

              csII.jpg

              • 4. Re: Combining two images like picture package and run it for all the images inside a folder
                pengzhuozhi Level 1

                Hi, thanks for this script, it will be very usefull, but i need vertical instead of horizontal

                 

                I've already changed the bold part in order do double height, but now i cant put the second image at bottom, could you help me?

                 

                Thanks in advance

                 

                 

                 

                #target photoshop

                main();

                function main(){

                var inputFolder = Folder.selectDialog("Please select the folder with Files to process");

                if(inputFolder == null) return;

                var startRulerUnits = preferences.rulerUnits;

                app.displayDialogs = DialogModes.NO;

                var outputFolder = Folder(inputFolder + "/Combined");

                if(!outputFolder.exists) outputFolder.create();

                var fileList = inputFolder.getFiles(/.jpg$/i);

                while(fileList.length>0){

                preferences.rulerUnits = Units.PIXELS;

                if(fileList.length==1) break;

                var mainDoc = open(fileList.shift());

                mainDoc.resizeCanvas(mainDoc.width, (mainDoc.height*2), AnchorPosition.TOPLEFT);

                var tmp = open(fileList.shift());

                tmp.activeLayer.duplicate(mainDoc);

                tmp.close(SaveOptions.DONOTSAVECHANGES);

                var LB = mainDoc.activeLayer.bounds;

                mainDoc.activeLayer.translate((mainDoc.width-LB[2].value),0);

                mainDoc.flatten();

                preferences.rulerUnits = Units.PERCENT;

                mainDoc.resizeImage(66.66666, undefined, undefined, ResampleMethod.BICUBICSHARPER);

                var saveFile = File(outputFolder + "/" + decodeURI(activeDocument.name));

                SaveJPEG(saveFile, 10);

                mainDoc.close(SaveOptions.DONOTSAVECHANGES);

                }

                preferences.rulerUnits = startRulerUnits;

                }

                function SaveJPEG(saveFile, jpegQuality){

                jpgSaveOptions = new JPEGSaveOptions();

                jpgSaveOptions.embedColorProfile = true;

                jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;

                jpgSaveOptions.matte = MatteType.NONE;

                jpgSaveOptions.quality = jpegQuality;

                activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);

                }

                 

                • 5. Re: Combining two images like picture package and run it for all the images inside a folder
                  Paul Riggott Level 6

                  Here you are...

                   

                   

                  #target photoshop
                  main();
                  function main(){
                  var inputFolder = Folder.selectDialog("Please select the folder with Files to process"); 
                  if(inputFolder == null) return;
                  var startRulerUnits = preferences.rulerUnits;
                  app.displayDialogs = DialogModes.NO;
                  var outputFolder = Folder(inputFolder + "/Combined");
                  if(!outputFolder.exists) outputFolder.create();
                  var fileList = inputFolder.getFiles(/.jpg$/i); 
                  while(fileList.length>0){
                  preferences.rulerUnits = Units.PIXELS;
                  if(fileList.length==1) break;
                  var mainDoc = open(fileList.shift());
                  mainDoc.resizeCanvas(mainDoc.width, (mainDoc.height*2), AnchorPosition.TOPLEFT);
                  var tmp = open(fileList.shift());
                  tmp.activeLayer.duplicate(mainDoc); 
                  tmp.close(SaveOptions.DONOTSAVECHANGES);
                  var LB = mainDoc.activeLayer.bounds;
                  mainDoc.activeLayer.translate(0,(mainDoc.height-LB[3].value));
                  mainDoc.flatten();
                  preferences.rulerUnits = Units.PERCENT;
                  mainDoc.resizeImage(66.66666, undefined, undefined, ResampleMethod.BICUBICSHARPER);
                  var saveFile = File(outputFolder + "/" + decodeURI(activeDocument.name));
                  SaveJPEG(saveFile, 10);
                  mainDoc.close(SaveOptions.DONOTSAVECHANGES);
                  }
                  preferences.rulerUnits = startRulerUnits;
                  }
                  function SaveJPEG(saveFile, jpegQuality){
                  jpgSaveOptions = new JPEGSaveOptions();
                  jpgSaveOptions.embedColorProfile = true;
                  jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
                  jpgSaveOptions.matte = MatteType.NONE;
                  jpgSaveOptions.quality = jpegQuality; 
                  activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
                  }