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

I need an action to stack multiple images (opened in ps) into multiple layers

New Here ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

Hi guys,

Hope somehone can help,

Can I create an action with this funcion? I usually move every image into the destination one as to create multiple layers, but how can I automatize it? I tried to create an action with Select, copy and paste but seems not working. I don't need the script>statistics>load file into stacks cause I need to open the image in photoshop first

Thanks in advance

TOPICS
Actions and scripting

Views

2.6K

Translate

Translate

Report

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 ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

No Actions can not use logic to retrieve the number of open document and their sizes then create a new document the correct size to house the currently open documents composite or Layers.  You would need to write a Photoshop Script to do that.

JJMack

Votes

Translate

Translate

Report

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
New Here ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

Thank you, how can I do it?

Votes

Translate

Translate

Report

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 ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

This code will create a new document with a good size canvas for of stack of their composites. With  SuperMerlin script  I do not know what you will wind up with if the open document are layered  and are different sizes and resolutions.  He is a better scripter than me. Still it looks to me that his script will only stack the active layer from  each of other open document and close them without saving them. Loosing any changes not saved in those documents.

/* ==========================================================
// 2016  John J. McAssey (JJMack) 
// Stack the open Document Visible layer composite into a new 300 DPI document
// This script is supplied as is. It is provided as freeware. 
// The author accepts no liability for any problems arising from its use.
// ======================================================= */
// enable double-clicking from Mac Finder or Windows Explorer
#target photoshop // this command only works in Photoshop CS2 and higher
// bring application forward for double-click events
app.bringToFront();

if (documents.length >= 2) { main(); }
else alert("multiple Document are not open in Photoshop");	
///////////////////////////////////////////////////////////////////////////////
//                            main function                                  //
///////////////////////////////////////////////////////////////////////////////
function main() {
	var orig_ruler_units = app.preferences.rulerUnits;
	var orig_display_dialogs = app.displayDialogs;
	app.preferences.rulerUnits = Units.PIXELS;				// set the ruler units to PIXELS
	app.displayDialogs = DialogModes.NO;					// Set Dialogs off
	var closeDocs  = prompt("Should documents be Close without saving?", "Yes");	
	var canvasSize = new Array();							// what size canvas is needed
	canvasSize=getDocDementions();							// get max width and height of open documents
	app.togglePalettes();									// toggle off palette so Photoshop will not need to update them
	var doc = app.documents.add( canvasSize[0], canvasSize[1], 300, "Stacked Opened Documents", NewDocumentMode.RGB, DocumentFill.TRANSPARENT ); // create a new document
	//for (var i=0;i<documents.length-1;i++) {				// stack a layer for the open document into the new document	
	for (var i=documents.length-2;i>-1;i--) {				// stack a layer for the open document into the new document
		app.activeDocument = documents[i];					// switch active document
		var layerName = app.activeDocument.name;			// get document name	
		app.activeDocument.selection.selectAll();           // select all
		try {app.activeDocument.selection.copy(true);}		// copy composite of visible layers to clipboard
		catch (e) {try {app.activeDocument.selection.copy();} // copy composite of visible layers to clipboard
				   catch (e) {app.purge(PurgeTarget.CLIPBOARDCACHE);} // empty 
			}
		app.activeDocument.selection.deselect();			// deselect
		app.activeDocument = documents[documents.length-1];	// switch to newly created document
		try { app.activeDocument.paste(); }					// paste on composite of visible layers
		catch (e) { app.activeDocument.artLayers.add();	}	// add an empty layer
		app.activeDocument.activeLayer.name=layerName;		// label layer with Document name
		}
	if ( closeDocs == "Yes" ) closeAllButOne();				// close all opened document except the newly created document	
	app.togglePalettes();									// toggle user's palettes back on	
	app.runMenuItem(charIDToTypeID(("FtOn")));				// fit the document to the screen 
	app.displayDialogs = orig_display_dialogs;				// Reset display dialogs 
	app.preferences.rulerUnits = orig_ruler_units;			// reset units to original settings
	}
///////////////////////////////////////////////////////////////////////////////
//                           main function end                               //
///////////////////////////////////////////////////////////////////////////////
function getDocDementions(){
    width=0;
	height=0;
	for (var i=0;i<documents.length;i++) {					// look at open document sizes
	    if (documents[i].width > width) width=documents[i].width;
		if (documents[i].height > height) height=documents[i].height;
		}
	return new Array(width, height);						// return width and height
	}
	
function closeAllButOne(){									// close all opened document except the newly created document
	while  (documents.length>1) {							
		app.activeDocument = documents[0];		
		activeDocument.close(SaveOptions.DONOTSAVECHANGES);
		}
	}
JJMack

Votes

Translate

Translate

Report

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
New Here ,
Jul 17, 2017 Jul 17, 2017

Copy link to clipboard

Copied

Thank you very much!!!

Votes

Translate

Translate

Report

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
New Here ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

Sorry I'm trying to run your script but here is the error

Error 8: Syntax Error

Line: 1

->  {\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf830

Votes

Translate

Translate

Report

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 ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

You are not trying my script line 1 in my script is a comment look at what I posted

  1. /* ==========================================================

 

Click on the link and save it to your machine http://www.mouseprints.net/old/dpr/StackOpenDocs.jsx as StackOpenDocs.jsx

JJMack

Votes

Translate

Translate

Report

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
New Here ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

Now works perfectly! Thank you!

Votes

Translate

Translate

Report

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 ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

The clue to the error is rtf, Rich Text Format therefore control characters are being added.

You need to copy and paste the script using a plain text editor

Votes

Translate

Translate

Report

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 ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

This code will stack all open documents into the first document.

#target photoshop;

while(app.documents.length>1){

app.activeDocument = app.documents[1];

var layerName = decodeURI(activeDocument.name).replace(/\....$/,'');

activeDocument.activeLayer.duplicate(documents[0]);

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

activeDocument.activeLayer.name = layerName;

};

Votes

Translate

Translate

Report

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 ,
Oct 19, 2019 Oct 19, 2019

Copy link to clipboard

Copied

Hey, how can i use this script step by step, I have no experiece in this.

Cheers

Votes

Translate

Translate

Report

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 ,
Oct 19, 2019 Oct 19, 2019

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 ,
Oct 28, 2019 Oct 28, 2019

Copy link to clipboard

Copied

LATEST

Thanks a lot!!

Votes

Translate

Translate

Report

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