Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

photoshop js code for imagemerege

Explorer ,
Feb 27, 2016 Feb 27, 2016

I have this js code i want to change the code that this code create a new merged file with the name of folder that content images i actually want to create a new folder named "merged_photos" and in that folder a new merged image named as folder name and after folder name just add "_merged"

please help me

#target photoshop 

var runphotomergeFromScript = true; // must be before Photomerge include

//@includepath "/Applications/Adobe Photoshop CS5/Presets/Scripts/"

//@include "Photomerge.jsx"

//@show include

var inputFolder = Folder.selectDialog("Choose the folder containing the folders with the images to merge:");

var foldersToMerge = inputFolder.getFiles( function( file ) { return file instanceof Folder; } );

// If you want to safe the photomerge output to a user defined location, uncoment the line below.

//var outputFolder = Folder.selectDialog("Choose the folder where you want to save the merged images:");

for( var i = 0; i < foldersToMerge.length; i++ ) {

var activeFolder= foldersToMerge;

var fileList = activeFolder.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( fileList.length > 1 ){

photomerge.createPanorama(fileList,false);

var tiffSaveOptions = new TiffSaveOptions();

//tiffSaveOptions.embedColorProfile = true;

tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;

//tiffSaveOptions.imageCompression = TIFFEncoding.NONE;

if (typeof outputFolder == "undefined") {

activeDocument.saveAs( new File(  activeFolder + '.tif'  ), tiffSaveOptions, );

}

else {

activeDocument.saveAs( new File( outputFolder + '/' + activeFolder.name + _merged + '.tif'  ), tiffSaveOptions, );

}

activeDocument.close( SaveOptions.DONOTSAVECHANGES );

TOPICS
Actions and scripting
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Feb 27, 2016 Feb 27, 2016

Looking at the code it looks like the code is there you just need to uncomment it.

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2016 Feb 27, 2016

but there is no code for crate new folder and i want to create new folder and named it merged_photo and place merged file on it

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2016 Feb 27, 2016

The code to create a mew folder is there but commented out. Also, you did not post the complete script.  I do not have CS5 installed. I changed what is there for CS6 added some closing brackets so the incomplete code would try to run. To see If I could create a new folder with the code as posted and new folder code uncommented.  I had no problem creating a new folder for the output....

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2016 Feb 27, 2016

Thanks Mack, i will posting complete code I just want that when merged process is completed than  a new folder is created named "merged_photos" and merge file image placed on that folder

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2016 Feb 27, 2016

hi mack, can you please tell me that how to add code that create folder? this code place merged file only in same folder  that contain images 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2016 Feb 27, 2016

Do you have the complete script?

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2016 Feb 27, 2016

this is the complete script

#target photoshop 
var runphotomergeFromScript = true; // must be before Photomerge include
//@includepath "/Applications/Adobe Photoshop CS5/Presets/Scripts/"
//@include "Photomerge.jsx"
//@show include
var inputFolder = Folder.selectDialog("Choose the folder containing the folders with the images to merge:");
var foldersToMerge = inputFolder.getFiles( function( file ) { return file instanceof Folder; } );
// If you want to safe the photomerge output to a user defined location, uncoment the line below.
//var outputFolder = Folder.selectDialog("Choose the folder where you want to save the merged images:");
for( var i = 0; i < foldersToMerge.length; i++ ) {
  var activeFolder= foldersToMerge[i];
  var fileList = activeFolder.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( fileList.length > 1 ){
  photomerge.createPanorama(fileList,false);
  
  var tiffSaveOptions = new TiffSaveOptions();
  //tiffSaveOptions.embedColorProfile = true;
  tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
  //tiffSaveOptions.imageCompression = TIFFEncoding.NONE;
  
  if (typeof outputFolder == "undefined") {
  activeDocument.saveAs( new File(  activeFolder + '.tif'  ), tiffSaveOptions, );
  }
  else {
  activeDocument.saveAs( new File( outputFolder + '/' + activeFolder.name + '.tif'  ), tiffSaveOptions, );
  }
  activeDocument.close( SaveOptions.DONOTSAVECHANGES );
  }
};
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2016 Feb 27, 2016

I have posted but it says Currently being moderated. any other way to post or edit my post? i am new here and dont know how to use this form.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2016 Feb 27, 2016

Yes those were the brackets I added. I also change it to cs6 and the input file type to jpg since I do not use Tif files I use  RAW, JPG, PNG, GIF, PSD etc but not Tiff.

As I wrote I had no problem creating a new folder for the output.

Capture.jpg

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2016 Feb 27, 2016

Hi Mack thank you for your cooperation you are great, that is good to use input files RAW, JPG, PNG, GIF, PSD but out files will be tif or jpg, seems there is no js code? can you please post js code so that i know what is wrong i am doing?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2016 Feb 28, 2016

I use the code you posted I just change tif to JPG for input. if you want to be able to use jpg, png, psd, psd, raw etc you will need to select all those types.  If it were my script I would output jpeg not tiff.

If you want a custom script you need to learn how to hack scripts.

To process any image file format you would use something like this, You could add additional file types

var fileList = activeFolder.getFiles(/\.(nef|cr2|crw|dcs|raf|arw|orf|dng|jpg|jpe|jpeg|tif|tiff|psd|eps|png|bmp)$/i);

I'm here to help you learn not to work for you.

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2016 Feb 28, 2016

var fileList = activeFolder.getFiles(/\.(nef|cr2|crw|dcs|raf|arw|orf|dng|jpg|jpe|jpeg|tif|tiff|psd|eps|p ng|bmp)$/i);


not working getting error

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2016 Feb 28, 2016

oky if you not interested to help me no problem at all, here internet so many people that share all their work and coding and you just tell me that you are not here to work for me....

I just ask for how to add code that create new folder that is not complete work i am asking to done by you.... i have share my complete code

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2016 Feb 28, 2016

I'm here to help you learn.

I do not know why the statement

  var fileList = activeFolder.getFiles(/\.(nef|cr2|crw|dcs|raf|arw|orf|dng|jpg|jpe|jpeg|tif|tiff|psd|eps|png|bmp)$/i);

did not work for  you. It works for me. Did you comment the statement it replaces out or remove it? There is no space in png the site mess with appends and add blanks at times.

Also, Photomerge has improved over the years. When Adobe first added the feature to Photoshop it worked very poorly. It was improved with each new release of Photoshop. So my results will be better than yours because I used CS6 and you CS5.  CC is better still  I have not tried the current cc 2015 version at lease one new option has been added.   Speaking about options I also changed the script to use the Auto option by uncommented the Auto setting and commenting the one that was not commented out.  I also changed the option set to false to true. Most of my "panoramas" are captured by hand, not on a tripod rotating around the lens nodal point. I find the setting I changed work for me.

The code to create a new folder is in the code you posted. It is commented out. There is and additional comment before it stating that you should uncomment it if you want to set the output folder. How many times do I have to write that?  The author of that script tried to make it easy for someone like you to change the code by providing that comment.

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2016 Feb 28, 2016

I just replace this line of code with your line

var fileList = activeFolder.getFiles( '*.tif' );


also i am using ps cs6 cc 2015

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2016 Feb 28, 2016

Capture.JPG

this is the error message.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2016 Feb 28, 2016

mirza5313 wrote:

I just replace this line of code with your line

var fileList = activeFolder.getFiles( '*.tif' );


also i am using ps cs6 cc 2015

The script you posted has CS5 hard coded into it????

//@includepath "/Applications/Adobe Photoshop CS5/Presets/Scripts/"

This site web code inserted a space in the line of code I posted.   |p ng| should be |png| when you dealing with programming you need to use your eye when something fails to see if something looks wrong....

If you install the script into CS6 and into CC it will fail if  "CS5" is not install for the script in including photomerge fron the CS5 install tree.

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 28, 2016 Feb 28, 2016

Remove the comment from this line.


//var outputFolder = Folder.selectDialog("Choose the folder where you want to save the merged images:");

to

var outputFolder = Folder.selectDialog("Choose the folder where you want to save the merged images:");

Once the script prompts you for the ouput folder, you can navigate to where you want the output folder and create one with a name of your choice.

No other changes or extra code is required.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2016 Feb 28, 2016

thanks merline, i want to create a folder in active document so should i write code like this?

var outputFolder = Folder.selectDialog("activeFolder:");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2016 Feb 28, 2016

and also i want to change the name of folder to "merged_photos" ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2016 Feb 28, 2016

mirza5313 wrote:

and also i want to change the name of folder to "merged_photos" ?

Then you select "merged_photos" or create a new folder and enter "merged_photos" as its name. You do that using the button in the bottom of select output folder dialog. Like I showed in the screen capture above. I too the default Name New Folder name.

Capture.jpg

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 28, 2016 Feb 28, 2016

No as I said before there is no more code for you to add.

If you want to create an output folder without being prompted for one that is something different:-

var outPutFolder = Folder("your path goes here");

I.E. var outPutFolder = Folder("/c/folder1/folder2/my new folder");

//This line creates the new folder.....

if(!outPutFolder.exists) outPutFolder.create();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2016 Feb 28, 2016

Hi can you please share the js code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2016 Feb 28, 2016
LATEST

Here is the code for CC 2015 I added the Content Aware Fill Transparent area option to be true.  Here is a link to the code so no extra spaces will be added: PhotoMergeFolders.jsx

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines