Automating Photomerge to run folder-batches

Discussion of Automation, Image Workflow and Raw Image Workflow

Moderators: Tom, Kukurykus

Mike Hale

Automating Photomerge to run folder-batches

Post by Mike Hale »

I did see your other post but I don't have an answer yet.

I'm facing a deadline on another project. If no one else has helped I'll try to find a fix when I can.
ccisystems

Automating Photomerge to run folder-batches

Post by ccisystems »

Thank you but I have received a working answer on the other post. Works perfectly.
mrmomar

Automating Photomerge to run folder-batches

Post by mrmomar »

Hi everyone,

I think this is a great script. However, I am wondering if anyone knows how to modify this script to operate as described below:

- 30+ files are in a single folder
- each panorama is composed of 3 files
- the script would consecutively photomerge 3 files at a time until the entire folder has been processed.

Thanks in advance for any assistance you can offer.
darkscout

Automating Photomerge to run folder-batches

Post by darkscout »

Funny... the day I get fed up doing this manually (and back from vacation) I found this thread.

Code: Select allvar runphotomergeFromScript = true; // must be before Photomerge include
//@includepath "/Applications/Adobe Photoshop CS4/Presets/Scripts/"
//@include "Photomerge.jsx"
//@show include
var psdOpts = new PhotoshopSaveOptions();
psdOpts.embedColorProfile = true;
psdOpts.alphaChannels = true;
psdOpts.layers = true;

var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality=12;
jpegOptions.scans=5;

var workFolder = Folder.selectDialog();
parseFolder(workFolder);

function parseFolder(folder) {
   var folders = folder.getFiles( function( file ) { return file instanceof Folder; } );
   var jpg= folder.getFiles("*.jpg");
   var dng= folder.getFiles("*.dng");
   var files=jpg.concat(dng);
   for(var i = 0; i < folders.length; i++ ) {
      try {
         parseFolder(folders);
      } catch(err) {
      }
   }
   if (files.length>0) {
      try {
         mergeImages(files);
      } catch (err) {
      }
   }
}

function mergeImages(fList) {
   // override Photomerge.jsx settings. Default is "Auto". Uncomment to override the default.
   photomerge.alignmentKey   = "Auto";
   //photomerge.alignmentKey   = "Prsp";
   //photomerge.alignmentKey   = "cylindrical";
   //photomerge.alignmentKey   = "spherical";
   //photomerge.alignmentKey   = "sceneCollage";
   //photomerge.alignmentKey   = "translation"; // "Reposition" in layout dialog
   // other setting that may need to be changed. Defaults below
   photomerge.advancedBlending      = true; // 'Bend Images Together' checkbox in dialog
   photomerge.lensCorrection      = true; // Geometric Distortion Correction'checkbox in dialog
   photomerge.removeVignette      = true; // 'Vignette Removal' checkbox in dialog
   if( fList.length >  0) {
      photomerge.createPanorama(fList,false);
   }
   // The merged doc will be the activeDocument
   activeDocument.saveAs( new File( fList[0].parent + '.psd' ) , psdOpts, true, Extension.LOWERCASE);
   activeDocument.saveAs( new File( fList[0].parent + '.jpg' ) , jpegOptions, true, Extension.LOWERCASE);
   activeDocument.close( SaveOptions.DONOTSAVECHANGES );
}

This does things recursively & works with dng or jpg files.

So if your folders are set up like this

Panoramas/Day 1/Grand Canyon/North/1-4.dng
Panoramas/Day 1/Grand Canyon/East/1-4.jpg
Panoramas/Day 1/Grand Canyon/South/1-4.jpg
Panoramas/Day 1/Pikes Peak/1-4.jpg
Panoramas/Day 2/1-4.jpg

Etc will spit out:
Panoramas/Day 1/Grand Canyon/North.jpg
Panoramas/Day 1/Grand Canyon/North.psd
Panoramas/Day 1/Grand Canyon/East.jpg
Panoramas/Day 1/Grand Canyon/East.psd
Panoramas/Day 1/Grand Canyon/South.jpg
Panoramas/Day 1/Grand Canyon/South.psd
Panoramas/Day 1/Pikes Peak.psd
Panoramas/Day 1/Pikes Peak.jpg
Panoramas/Day 2.jpg
Panoramas/Day 2.psd[/code]
darkscout

Automating Photomerge to run folder-batches

Post by darkscout »

Another one I setup last night. I often do numerous types of panoramas and 'auto' doesn't always select the best one for me. This chunks through all the different types of Panoramas and spits a file out for each one. Takes a while, but I can set it up and leave it for the night and come back in the morning and delete anything I don't like faster than I can sit there and watch Photoshop run.

Code: Select allvar runphotomergeFromScript = true; // must be before Photomerge include
//@includepath "/Applications/Adobe Photoshop CS4/Presets/Scripts/"
//@include "Photomerge.jsx"
//@show include
var psdOpts = new PhotoshopSaveOptions();
psdOpts.embedColorProfile = true;
psdOpts.alphaChannels = true;
psdOpts.layers = true;

var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality=12;
jpegOptions.scans=5;

var workFolder = Folder.selectDialog();
parseFolder(workFolder);

function parseFolder(folder) {
   var folders = folder.getFiles( function( file ) { return file instanceof Folder; } );
   var jpg= folder.getFiles("*.jpg");
   var dng= folder.getFiles("*.dng");
   var files=jpg.concat(dng);
   for(var i = 0; i < folders.length; i++ ) {
      try {
         parseFolder(folders);
      } catch(err) {
      }
   }
   if (files.length>0) {
      try {
         mergeImages(files);
      } catch (err) {
         alert(err);
      }
   }
}

function mergeImages(fList) {
   var alignmentKeys=Array("Prsp","cylindrical","spherical","sceneCollage","translation");
   for (var j=0; j< alignmentKeys.length; j++) {
      // override Photomerge.jsx settings. Default is "Auto". Uncomment to override the default.
      photomerge.alignmentKey=alignmentKeys[j];
      //photomerge.alignmentKey   = "Auto";
      //photomerge.alignmentKey   = "Prsp";
      //photomerge.alignmentKey   = "cylindrical";
      //photomerge.alignmentKey   = "spherical";
      //photomerge.alignmentKey   = "sceneCollage";
      //photomerge.alignmentKey   = "translation"; // "Reposition" in layout dialog
      // other setting that may need to be changed. Defaults below
      photomerge.advancedBlending      = true; // 'Bend Images Together' checkbox in dialog
      photomerge.lensCorrection      = true; // Geometric Distortion Correction'checkbox in dialog
      photomerge.removeVignette      = true; // 'Vignette Removal' checkbox in dialog
      if( fList.length >  0) {
         photomerge.createPanorama(fList,false);
      }
      // The merged doc will be the activeDocument
      // activeDocument.saveAs( new File( fList[0].parent + '.psd' ) , psdOpts, true, Extension.LOWERCASE);
      activeDocument.saveAs( new File( fList[0].parent +"." + alignmentKeys[j] + '.jpg' ) , jpegOptions, true, Extension.LOWERCASE);
      activeDocument.close( SaveOptions.DONOTSAVECHANGES );
   }
}
Mike Hale

Automating Photomerge to run folder-batches

Post by Mike Hale »

If you want to set scans in the jpg options you also need to set formatOptions = FormatOptions.PROGRESSIVE;