Copy link to clipboard
Copied
Can someone help me how to perform this process?
Automatically combine two images into one layered PSD or TIFF image, then save.
Let's say I have a bunch of original images and retouched images in a folder.
Like this,
image_01.tiff
image_01_retouched.tiff
image_02.tiff
image_02_retouched.tiff
I would like some kind of script to automatically add retouched image into the second layer in the original image and then save the file. (It would be amazing if it could also change the file names as well)
Is this possible?
I'm doing this manually, and as you can guess, it's painful.
By opening both images and dragging the retouched image into the original image. Then save the file.
I have cleaned up the code a little bit from the generic script previously posted and changed over to layered TIFF output:
/*
Stack x2 Image Sets to Layered TIFF.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-automatically-add-two-images-into-layer-in-a-single-psd-or-tiff-then-save/m-p/13897545
v1.0 - 28th June 2023, Stephen Marsh
* This script requires input files from a single folder to be alpha/numeric sorting in order to stack in the correc
...
Let's make a minor change to the previous code to retain the Background layer, as that may be the only thing you need!
Find the following chunk of code:
// Set the base doc layer name
app.activeDocument = documents[0];
docNameToLayerName();
Delete or comment out // the 3rd line #78 for docNameToLayerName();
// Set the base doc layer name
app.activeDocument = documents[0];
//docNameToLayerName();
If required, further refinements can be made as previously discussed, a
...Hi @Stephen Marsh
If I run the script as they are, the layer order will flip in the stacked file.
By @hosongn52153496
Find the following section in the code:
// Force alpha-numeric list sort
// Use .reverse() for the first filename in the merged file
// Remove .reverse() for the last filename in the merged file
fileList.sort().reverse();
Then change the last line #36 to:
// Force alpha-numeric list sort
// Use .reverse() for the first filename in the merged file
// Remove .reverse() fo
...
Copy link to clipboard
Copied
Let's make a minor change to the previous code to retain the Background layer, as that may be the only thing you need!
Find the following chunk of code:
// Set the base doc layer name
app.activeDocument = documents[0];
docNameToLayerName();
Delete or comment out // the 3rd line #78 for docNameToLayerName();
// Set the base doc layer name
app.activeDocument = documents[0];
//docNameToLayerName();
If required, further refinements can be made as previously discussed, automatically saving the layered TIFF files into a subfolder without the prompt for you to select a folder.
Copy link to clipboard
Copied
Hi @Stephen Marsh !
It works wonderfully! However, in my testing, the script won't work if the new file with the suffix is followed by '-' (dash)but works with '_' (underscore)
Is there a way to make the script work with dash as well or dash only? For example,
Filename-top.tif
Copy link to clipboard
Copied
Ah, I'll need to look into that, you didn't previously mention the filename formatting and there's nothing explicitly in there that I recall that would treat hyphens and underscores differently. Are you on Windows or Mac?
Copy link to clipboard
Copied
Sorry about not mentioning it.
I'm on Mac.
Copy link to clipboard
Copied
So pairs of files, such as:
Filename001.tif
Filename001-top.tif
Filename002.tif
Filename002-top.tif
etc.?
The script simply uses natural alpha-numeric sorting, it's not explicitly trying to find patterns.
It might be better if you provided real filename examples for testing.
Copy link to clipboard
Copied
Hi @Stephen Marsh
Your example is correct, but here are a few real file names.
526842A-Black_MC_068-top.tif
526842A-Black_MC_068.tif
8542156C-Red_MC_022-top.tif
8542156C-Red_MC_022.tif
If I run the script as they are, the layer order will flip in the stacked file.
If I change the hyphen to underscore, everything works perfectly.
The top layer file is automatically generated; I can't change it to underscore when generated.
I can only rename them afterward, but I want to see if I can skip that step if possible.
Copy link to clipboard
Copied
Hi @Stephen Marsh
If I run the script as they are, the layer order will flip in the stacked file.
By @hosongn52153496
Find the following section in the code:
// Force alpha-numeric list sort
// Use .reverse() for the first filename in the merged file
// Remove .reverse() for the last filename in the merged file
fileList.sort().reverse();
Then change the last line #36 to:
// Force alpha-numeric list sort
// Use .reverse() for the first filename in the merged file
// Remove .reverse() for the last filename in the merged file
fileList.sort();
Does that fix the layer order issue?
Copy link to clipboard
Copied
I just tested this, and it works perfectly!
You are a genius!
Thank you, thank you, thank you!!!
Copy link to clipboard
Copied
That’s great, I didn’t expect the file sort order to be different between a hyphen and an underscore suffix separator!
Copy link to clipboard
Copied
On a related note, I built a generic script with a GUI – "Stack Documents to Sets of N Layers" (this script doesn't retain the Background layer of the first doc, the expectation is that files are flattened or have single layers):
Find more inspiration, events, and resources on the new Adobe Community
Explore Now