Skip to main content
Participant
October 7, 2015
Pregunta

Photomerge Automation

  • October 7, 2015
  • 1 respuesta
  • 2109 visualizaciones

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!

Este tema ha sido cerrado para respuestas.

1 respuesta

JJMack
Community Expert
Community Expert
October 7, 2015

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

Analysis and automatic classification of a batch of images

Autopano Features Group View

Do you have a folder or a memory card full of photos? Launch detection on all images; Autopano groups together only those images that make up panoramas and ignores all irrelevant images. No need to specify the order of images in each view: Autopano will find them by itself. The detection power of Autopano is much better than the human eye, so the software can find relationships that you might have missed visually.

JJMack
Participant
October 8, 2015

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?

SuperMerlin
Inspiring
October 8, 2015

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.