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
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.
Copy link to clipboard
Copied
Thank you, how can I do it?
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);
}
}
Copy link to clipboard
Copied
Thank you very much!!!
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
Copy link to clipboard
Copied
You are not trying my script line 1 in my script is a comment look at what I posted
Click on the link and save it to your machine http://www.mouseprints.net/old/dpr/StackOpenDocs.jsx as StackOpenDocs.jsx
Copy link to clipboard
Copied
Now works perfectly! Thank you!
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
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;
};
Copy link to clipboard
Copied
Hey, how can i use this script step by step, I have no experiece in this.
Cheers
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks a lot!!