Copy link to clipboard
Copied
Hi all,
I'm curious whether the following scenario is feasible in Photoshop with Batch processing:
Let's say I have 100 images, in 10 sub-folders under a main folder. Each folder contains 10 images.
I'd like to open all image in all of these folders one-by-one as *Layers* and do exactly the same processing on each set (these steps would be part of the custom Action, something like: merge the layers visually by making them "Lighten" type and then add gradually degreasing brightness in order of the layers using Clipping Mask) and then save the layers as a new image in an Output folder.
I've made it as far as preparing an Action that contained File -> Scripts -> "Load Files into Stack" as the first step to open the files in the 10 sub-folders one by one as layers and apply the processing steps in the Action afterwards.
The problem arose when I kicked off the Action with File -> Automate -> Batch, because the "Load Files into Stack" popup window simply blocks the process even if I tick the "Suppress File Open Options Dialogs" on the Batch setup window. It just hangs there waiting for my input...
Is there really no way around this? With the normal Open option - that Batch can suppress - I can't open these set of 10 files as layers and I really need to find a way to be able to work on multiples of sets of 10 images in a repetative way and then merge them into 1 file. Anybody knows another way maybe to do this?
Thanks a lot!
/András
»Is there really no way around this?«
The obvious solution would be abandoning Batch and creating (or using) a proper Scripting.
How good are you with JavaScript?
I did a quick search on this Forum and I haven’t found a Script that would seem to meet your needs immediately
Maybe you should start a new thread with a more Script-oriented title to attract additional attention.
Personally I would probably start with a Folder-selection dialog (for the top Folder), then get Arrays for the files within the sub-Folders, then open the respective first and load the others and use Auto-Align Layers (if you use that in the »Load Files into Stack«-Script so far) and s
...Copy link to clipboard
Copied
»Is there really no way around this?«
The obvious solution would be abandoning Batch and creating (or using) a proper Scripting.
How good are you with JavaScript?
Copy link to clipboard
Copied
I see, wasn't aware of any such options. I'd imagine good enough, I'm a software dev. Googled a bit now, wow, a whole new world... Still, would appreciate if you would have some pointers for me to start.
Copy link to clipboard
Copied
I did a quick search on this Forum and I haven’t found a Script that would seem to meet your needs immediately
Maybe you should start a new thread with a more Script-oriented title to attract additional attention.
Personally I would probably start with a Folder-selection dialog (for the top Folder), then get Arrays for the files within the sub-Folders, then open the respective first and load the others and use Auto-Align Layers (if you use that in the »Load Files into Stack«-Script so far) and save the files to the output-Folder.
The selection, opening, saving should all work well enough with Document Object Model-code (DOM), but selecting all the layers and auto-aligning them for example may take Action Manager-code (AM).
One can generate that by using the ScriptingListener.plugin and wrapping the code it generates into functions.
Copy link to clipboard
Copied
Awesome, thank you for you for checking, this helps a lot! Will proceed accordingly
Copy link to clipboard
Copied
There are other Forum-regulars who are more Scripting-savvy than me, so if you hit some obstacle start a new thread on the specific issue and I expect some of them might chime in.
Unfortunately … this may not be a great time to start with »traditional« Scripting in Photoshop.
There are changes afoot (the switch from CEP to UXP) and support for »classic« Scripts will supposedly be adandoned at some so-far-unannounced point in the future.
https://www.adobe.io/photoshop/uxp/guides/
https://www.davidebarranca.com/development/adobe-uxp-things-you-need-to-know
Copy link to clipboard
Copied
Adobe seems to have grands plans will they have more success with UXP then they had with DGN.
IMO it looks like it will be rocky road with all the changes Microsoft, Apple and Adobe have in plain. I think there will be a lot of carnage and legacy encampments. There is too much invested in legacy software to be written off. And there a great depemdancy now on current legacy software. UXP is Adobe next DGN IMO something that will co exist.
Copy link to clipboard
Copied
Let’s hope so.
Copy link to clipboard
Copied
If there is still interest, I have a couple of options that may fast-track the process.
Copy link to clipboard
Copied
Of course, shoot!
Copy link to clipboard
Copied
I have made very minor adjustments to one of JJMack's scripts here (forcing alpha-numeric sorting and some other options around line 587 or so):
https://github.com/MarshySwamp/Layer-Stack-N-Number-of-Files-Filename-as-Top-Layer
You will need both scripts in the same location, as the main script requires the prefs script.
You will need to create a template file the same size as the input images. The template file has to be flattened with a background layer, it also has to have 10 white alpha channels named:
Image 1
Image 2
...
Image 10
That is it!
PSD files are saved as the default output method, you will end up with 10 layers per combined PSD image. Note: each layer is a smart object (you may need to modify the script or adjust your layer processing action). You may also wish to remove the redundant alpha channel from the resulting output files.
At this point, you would need to process each layered file with your action as a second, separate process (Batch, Image Processor, Image Processor Pro, Picture Processor etc).
If you dig into JJMack's code, you could of course add some code to process the layers, so that a second bulk processing step is not required. I'll leave that up to you.
Copy link to clipboard
Copied
Here is a different approach, I have modified a script created for working on pairs of images into one that works on sets of ten images.
This script will only process a single top-level folder, so you would need a root-level folder of 100 images, not a root-level folder containing 10 sub-folders of 10 images each.
All you need to do is point it at a source folder and it will create layered TIFF versions with layers in stacks of 10. There is no error checking to ensure that the source folder contains multiples of 10 images. There is placeholder code to run an action from the actions panel before saving each layered file. The TIFF saving options can be swapped out for a different file format. The code could be optimised, I'm just a newb at scripting so it is a bit rough but it does the job. I have tried to comment the code at key points to explain what is taking place. Hope this helps!
/*
Combine images into 10 layers.jsx
by Stephen Marsh - 2020
https://community.adobe.com/t5/photoshop/batch-processing-mutiple-set-of-images-as-layers/m-p/11714886
Code based on the following topic thread:
https://community.adobe.com/t5/photoshop/open-photos-with-same-filename-as-layers/td-p/11515954
NOTE:
* No Files should be open.
* There is no error checking, the input folder should contain even quantities of 10 alphabetically sorting images.
* It is assumed that all files contain only a single image layer (flat or layered).
* It is also assumed that all files have the same pixel width, height and resolution.
*/
#target photoshop
/* Start Open Document Error Check - Part A: If */
if (app.documents.length === 0) {
(function () {
var restoreDialogMode = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
inputFolder = Folder.selectDialog("Please select the folder with multiples of 10 alphabetically sorting files:");
if (inputFolder === null) return;
var newPath = Folder(decodeURI(inputFolder + "/Combined")); // Create sub-dir
if (!newPath.exists) newPath.create();
var fileList = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|png|psd)$/i); // Limit file format input
fileList.sort(); // Force alpha-numeric list sort, to reverse the sort order use .sort.reverse();
var inputCount = fileList.length;
var cancelScript = confirm(inputCount + " input files stacked into sets of 10 will produce " + inputCount / 10 + " layered files. Press 'Yes' to continue or 'No' to cancel.");
// Test if no returns false, then terminate the script
if (cancelScript === false) {
alert('Script cancelled!');
return;
}
while (fileList.length) {
for (var a = 0; a < 10; a++) { // Loop through 10 images
try {
app.open(fileList.pop());
} catch (e) { }
}
// Call the function named: processFiles
processFiles();
}
alert("Files saved to '" + inputFolder + "/Combined'");
function processFiles() {
try {
var Name = app.documents[0].name.replace(/\.[^\.]+$/, ''); // Remove file extension
/* There must be a better way, however, this was the quickest way to modify the existing script from 2 to 10 layers... */
// Document 2 to Document 1
app.activeDocument = documents[1];
app.activeDocument.activeLayer.duplicate(documents[0]);
// Document 3 to Document 1
app.activeDocument = documents[2];
app.activeDocument.activeLayer.duplicate(documents[0]);
// Document 4 to Document 1
app.activeDocument = documents[3];
app.activeDocument.activeLayer.duplicate(documents[0]);
// Document 5 to Document 1
app.activeDocument = documents[4];
app.activeDocument.activeLayer.duplicate(documents[0]);
// Document 6 to Document 1
app.activeDocument = documents[5];
app.activeDocument.activeLayer.duplicate(documents[0]);
// Document 7 to Document 1
app.activeDocument = documents[6];
app.activeDocument.activeLayer.duplicate(documents[0]);
// Document 8 to Document 1
app.activeDocument = documents[7];
app.activeDocument.activeLayer.duplicate(documents[0]);
// Document 9 to Document 1
app.activeDocument = documents[8];
app.activeDocument.activeLayer.duplicate(documents[0]);
// Document 10 to Document 1
app.activeDocument = documents[9];
app.activeDocument.activeLayer.duplicate(documents[0]);
// Set Document 1 as the target for further processing
app.activeDocument = documents[0];
/* There should now be 10 layers! Do something else, such as run an action? */
// If so, uncomment the line below and change the action and action set as required...
//app.doAction("MyAction", "MyActionSet");
app.displayDialogs = restoreDialogMode;
} catch (e) { }
var saveFile = File(newPath + "/" + Name + "_Combined" + ".tif");
// Call the function named: saveTIFF
saveTIFF(saveFile);
// Close all open docs without saving
while (app.documents.length) {
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}
function saveTIFF(saveFile) {
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.byteOrder = ByteOrder.IBM;
tiffSaveOptions.transparency = true;
tiffSaveOptions.layers = true;
tiffSaveOptions.layerCompression = LayerCompression.ZIP;
tiffSaveOptions.interleaveChannels = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.annotations = true;
tiffSaveOptions.spotColors = true;
tiffSaveOptions.saveImagePyramid = false;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW; // NONE | JPEG | TIFFLZW | TIFFZIP
app.activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
}
})();
}
/* Finish Open Document Error Check - Part A: If */
/* Start Open Document Error Check - Part B: Else */
else {
alert('Please close all open documents before running this script!');
}
/* Finish Open Document Error Check - Part B: Else */
Copy link to clipboard
Copied
So, did either of those two scripts help?
EDIT: Another option here for sets of 3, it is easy enough to change it for sets of 10, however it is really slow compared to my script above as it uses the load files into stack script.