Hi,
I'm taking a lot of panoramic images, anything between 5 and 13 exposures. I found Photoshop's "Photomerge" function works best for stitching them together.
My workflow is to save the source files for each panorama inside a separate folder: For example "Pano1" contains 5 files, "Pano2" contains 7 files, "Pano3" contains 9 files.
Is there a way of automating/telling Photoshop to take all the images inside a folder and stitch/photomerge them together to a panorama, and then proceed to the next folder,... until all folders are processed.
I've got very basic knowledge of programming languages: I guess I'd understand the basics of what a script does & modify an exisiting script – but I couldn't code something myself.
Can someone here please help me?
Thanks a lot!
CPixie
Automating Photomerge to run folder-batches
Automating Photomerge to run folder-batches
This should be close to what you what.
Code: Select allvar runphotomergeFromScript = true; // must be before Photomerge include
//@includepath "/c/Program Files/Adobe/Adobe Photoshop CS4/Presets/Scripts/"
//@include "Photomerge.jsx"
//@show include
var workFolder = Folder.selectDialog();
var fList = workFolder.getFiles( '*.tif' );
// 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 = false; // Geometric Distortion Correction'checkbox in dialog
photomerge.removeVignette = false; // 'Vignette Removal' checkbox in dialog
if( fList.length > 1 ){
photomerge.createPanorama(fList,false);
}
// The merged doc will be the activeDocument
Code: Select allvar runphotomergeFromScript = true; // must be before Photomerge include
//@includepath "/c/Program Files/Adobe/Adobe Photoshop CS4/Presets/Scripts/"
//@include "Photomerge.jsx"
//@show include
var workFolder = Folder.selectDialog();
var fList = workFolder.getFiles( '*.tif' );
// 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 = false; // Geometric Distortion Correction'checkbox in dialog
photomerge.removeVignette = false; // 'Vignette Removal' checkbox in dialog
if( fList.length > 1 ){
photomerge.createPanorama(fList,false);
}
// The merged doc will be the activeDocument
Automating Photomerge to run folder-batches
Hi Mike,
Thanks a lot for the script! I'm working in OSX, so I've tweaked the includepath a little.
I placed the script inside the same scripts folder as the Photomerge script, started up Photoshop and ran it from the File/Scripts menu.
It works fine – but only for the folder I specify in the beginning. Not for a whole batch of folders. I tried implementing your script into a 'normal' Photoshop action, then go "File/Automate/Batch..." and select "include subfolders", but it won't work that way.
Maybe I should explain my folder structure/workflow a bit better:
Panoramas/Pano1/File1.tif
Panoramas/Pano1/File2.tif
Panoramas/Pano1/File3.tif
Panoramas/Pano2/File1.tif
Panoramas/Pano2/File2.tif
Panoramas/Pano2/File3.tif
Panoramas/Pano2/File4.tif
Panoramas/Pano2/File5.tif
Panoramas/Pano3/File1.tif
Panoramas/Pano3/File2.tif
Panoramas/Pano3/File3.tif
Panoramas/Pano3/File4.tif
...and so on.
What I'd like to do is: Set/select the workfolder (in my example "Panoramas"), so that the script then automatically works it's way through the subfolders ("Pano1", "Pano2",...) and automatically merges all the files inside a subfolder to a panorama & then moves on to the next subfolder for a new panorama.
Ideally, the results/panoramas would be saved automatically (filename could be the same as the subfolder names, for example).
Thanks a lot for your time & input!
CPixie
Thanks a lot for the script! I'm working in OSX, so I've tweaked the includepath a little.
I placed the script inside the same scripts folder as the Photomerge script, started up Photoshop and ran it from the File/Scripts menu.
It works fine – but only for the folder I specify in the beginning. Not for a whole batch of folders. I tried implementing your script into a 'normal' Photoshop action, then go "File/Automate/Batch..." and select "include subfolders", but it won't work that way.
Maybe I should explain my folder structure/workflow a bit better:
Panoramas/Pano1/File1.tif
Panoramas/Pano1/File2.tif
Panoramas/Pano1/File3.tif
Panoramas/Pano2/File1.tif
Panoramas/Pano2/File2.tif
Panoramas/Pano2/File3.tif
Panoramas/Pano2/File4.tif
Panoramas/Pano2/File5.tif
Panoramas/Pano3/File1.tif
Panoramas/Pano3/File2.tif
Panoramas/Pano3/File3.tif
Panoramas/Pano3/File4.tif
...and so on.
What I'd like to do is: Set/select the workfolder (in my example "Panoramas"), so that the script then automatically works it's way through the subfolders ("Pano1", "Pano2",...) and automatically merges all the files inside a subfolder to a panorama & then moves on to the next subfolder for a new panorama.
Ideally, the results/panoramas would be saved automatically (filename could be the same as the subfolder names, for example).
Thanks a lot for your time & input!
CPixie
Automating Photomerge to run folder-batches
This should work with one level of folders. Note that I did not test it.
Code: Select allvar runphotomergeFromScript = true; // must be before Photomerge include
//@includepath "/c/Program Files/Adobe/Adobe Photoshop CS4/Presets/Scripts/"
//@include "Photomerge.jsx"
//@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 fList = workFolder.getFiles( '*.tif' );
// 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 = false; // Geometric Distortion Correction'checkbox in dialog
photomerge.removeVignette = false; // '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 + '/completed.psd' ) , psdOpts, true, Extension.LOWERCASE);
activeDocument.close( SaveOptions.DONOTSAVECHANGES );
}
Code: Select allvar runphotomergeFromScript = true; // must be before Photomerge include
//@includepath "/c/Program Files/Adobe/Adobe Photoshop CS4/Presets/Scripts/"
//@include "Photomerge.jsx"
//@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 fList = workFolder.getFiles( '*.tif' );
// 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 = false; // Geometric Distortion Correction'checkbox in dialog
photomerge.removeVignette = false; // '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 + '/completed.psd' ) , psdOpts, true, Extension.LOWERCASE);
activeDocument.close( SaveOptions.DONOTSAVECHANGES );
}
Automating Photomerge to run folder-batches
Code: Select all var fList = workFolder.getFiles( '*.tif' );
should probably be
Code: Select all var folder = folders;
var fList = folder.getFiles( '*.tif' );
And, of course, I haven't tested either
-X
should probably be
Code: Select all var folder = folders;
var fList = folder.getFiles( '*.tif' );
And, of course, I haven't tested either
-X
Automating Photomerge to run folder-batches
Your right X. I forgot to change that when I put in the loop.
Automating Photomerge to run folder-batches
Thanks a lot guys - works a treat! The only thing that doesn't work is the file-saving. (Error 2: flist is undefined). But that's no problem, as I'll just run the panoramas in batches of 10 and then save them manually..
CPixie
CPixie
Automating Photomerge to run folder-batches
Mike Hale wrote: // The merged doc will be the activeDocument
activeDocument.saveAs( new File( flist[0].parent + '/completed.psd' ) , psdOpts, true, Extension.LOWERCASE);
activeDocument.close( SaveOptions.DONOTSAVECHANGES );
}[/code]
This script is brilliant! One issue I have hit though, is if the panoramas are larger than what PSD supports, even if you specify '.psd' in the saveAs options, Photoshop stops the processing and asks for a file name for a .psb file. I know that's the file format for large documents but specifying .psb in the file saveAs does not help -- Photoshop still prompts for the file name and path. Not very helpful when wanting to let it run unattended. Does anyone have a clue why it does not just save like it does with psd? Much appreciated. I posted this question with example code I am using in the 'Help Me' forum but nobody seems to have an idea there.
activeDocument.saveAs( new File( flist[0].parent + '/completed.psd' ) , psdOpts, true, Extension.LOWERCASE);
activeDocument.close( SaveOptions.DONOTSAVECHANGES );
}[/code]
This script is brilliant! One issue I have hit though, is if the panoramas are larger than what PSD supports, even if you specify '.psd' in the saveAs options, Photoshop stops the processing and asks for a file name for a .psb file. I know that's the file format for large documents but specifying .psb in the file saveAs does not help -- Photoshop still prompts for the file name and path. Not very helpful when wanting to let it run unattended. Does anyone have a clue why it does not just save like it does with psd? Much appreciated. I posted this question with example code I am using in the 'Help Me' forum but nobody seems to have an idea there.
Automating Photomerge to run folder-batches
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.
I'm facing a deadline on another project. If no one else has helped I'll try to find a fix when I can.