Photomerge Automation
Hello everyone. I have a dataset that consists of several thousand historical aerial photos and I am trying to use a script to automate the stitching process. I originally got the idea from This blog post which seems to be capable of doing everything that I need but I cannot get it to run. Below is the version of that script with a few of my edits and questioning comments.
var runphotomergeFromScript = true; // must be before Photomerge include
"C:/Program Files (x86)/Adobe/Adobe Photoshop CC/Presets/Scripts"
"Photomerge.jsx" //including this on the previous line stops the original dialogue from opening
//@show include
psdOpts = new PhotoshopSaveOptions();
psdOpts.embedColorProfile = true;
psdOpts.alphaChannels = true;
psdOpts.layers = true;
var workFolder = Folder.selectDialog();
var folders = workFolder.getFiles( function( file ) { return file instanceof Folder; } );
for( var i = 0; i < folders.length; i++ )
{
var folder = folders;
var fList = folder.getFiles( '*.tif' ); //changed to .tif
// override Photomerge.jsx settings. Default is "Auto". Uncomment to override the default.
photomerge.alignmentKey = "Auto"; //when the script gets to this point it returns "photomerge is undefined"
//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 = false; // Geometric Distortion Correction'checkbox in dialog
photomerge.removeVignette = true; // 'Vignette Removal' checkbox in dialog
if( fList.length > 1 )
{
photomerge.createPanorama(fList,false);
}
// The merged doc will be the activeDocument
// activeDocument.saveAs( new File( fList[0].parent + '/Stitch.psb' ) , psdOpts, true, Extension.LOWERCASE);
// try to always save as psb for larger files
savePSB(fList[0].parent + '/Stitch.psb');
activeDocument.close( SaveOptions.DONOTSAVECHANGES );
}
function savePSB(fileNameAndPath) //function added in order to save large files
{
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
var desc19 = new ActionDescriptor();
var desc20 = new ActionDescriptor();
desc20.putBoolean( sTID('maximizeCompatibility'), true );
desc19.putObject( cTID('As '), cTID('Pht8'), desc20 );
desc19.putPath( cTID('In '), new File( fileNameAndPath ) );
desc19.putBoolean( cTID('LwCs'), true );
executeAction( cTID('save'), desc19, DialogModes.NO );
};
When I run this script, a dialogue in photoshop opens and asks me for the file I wish to begin with (as it should). But once the script gets to line 26 it returns "photomerge is undefined" which makes me think that I have made a mistake in the very first lines of the script in which I link this script to Adobe's original Photomerge.jsx script. So essentially I am just looking to understand more about the @includepath lines that were included in the original code and how I can correctly relate this script to the original so that I can reference the photomerge object/function. Sorry for my lack of experience, any help would be greatly appreciated!
