Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
I think I read somewhere that at least one of the application in the marketplace designed as a dedicated stitching application. Can stitch all the files in a input folder of image file that can be stitched into a collection of stitched panoramas in an output folder. Without needing human interaction. I seem to remember that stitching application was Autopano Pro. I have not used that application I just read it was one of the best stitching applications and had a feature like that. Then my memory is not as good as it use to be. However if you has thousands of images it may be worth having a look. There my be a free trial or a crippled demo version.
I just did a search and found this Kolor | Features of Autopano - panorama software
Copy link to clipboard
Copied
Thank you for your input. I'll do some research on Autopano and see if it is capable of doing what I need. The real trouble I'm having is determining a way to start with a main folder and make panoramas of the images contained in the files that are contained in that main folder. So it's not just 1 folder full of image files.
I should have specified what my directory looks like:
>Wisconsin_Historical_Aerial_Photos
>20101
>aerial34488_2010124.tif
>aerial34489_2010125.tif
>etc...there are 30-45 of these images in each folder
>20102
>20103
>etc...there are about 1.6k of these folders. Each corresponds to a township in Wisconsin. I used a python script to organize the images in this way because I need them to have this the township number at least somewhere in the name of the panorama so that it can eventually be spatially related to the rest of our database.
Thanks again for your time. Are you able to shed any light on what @includepath really means?
Copy link to clipboard
Copied
You are not calling the Photomerge script
Change the first four lines of code:-
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
To:-
var runphotomergeFromScript = true;
$.evalFile(app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts") + "/Photomerge.jsx");
Then see if there any more errors.
Copy link to clipboard
Copied
"File or folder does not exist."
("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts")
Could it be because of this part? I don't think I have a ScriptingSupport or InstalledScripts folder on my computer.
Copy link to clipboard
Copied
You need to check if the folder and script exist in your Application Presets/Scripts folder.
If not it may require a re-install as the script will not work without it.
Copy link to clipboard
Copied
The Presets/Scripts folders exist with Photomerge.jsx inside. The Presets folder is located directly within the Adobe Photoshop CC folder.
Copy link to clipboard
Copied
That is strange, it should then work.
You could run this as a separate script to see what is happening.
#target photoshop;
var file = new File(app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts") + "/Photomerge.jsx");
if(!file.exists){
alert("Cannot find this file\n The folder will now open so that you can view the files.");
new Folder(app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts")).execute();
}else{
alert("file exists");
};
Copy link to clipboard
Copied
Strange. So the only difference there is that in the original script that line begins with $.evalFile instead of just File. Unfortunately I'm a bit too novice with Javascript to understand what that difference means.
Edit:Maybe it is because I'm working on a computer that I do not have full access to? I will try to get administrative permission and run the script again. And thank you again for your input!
Copy link to clipboard
Copied
Ah, I see you are running the script from ExtendScript Toolkit, in that case make sure you put:-
#target photoshop;
as the first line in the other script and try again, it could be you hadn't set the target to Photoshop before running the script.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now