Copy link to clipboard
Copied
Hi everyone. I really need your help. I'm trying to find a script that can convert all alpha channels into different layers and if one or more alpha channels is/are empty/black to be deleted.
Thank you
You are right, Apply Image might also be faster.
// create layers for channels that are not empty in rgb images;
// 2020, use it at your own risk;
if (app.documents.length > 0) {
if (activeDocument.mode == DocumentMode.RGB) {
var theChannels = collectChannels ();
activeDocument.selection.deselect();
// create layers;
for (var m = theChannels.length-1; m >= 0; m--) {
loadAndLayer (theChannels[m][1], theChannels[m][0], [0,0,0]);
};
};
};
////// collect layers //////
function collectChannels () {
/
...
Copy link to clipboard
Copied
Looks good
Copy link to clipboard
Copied
Hello!! Can this work with CMYK as well? Thanks!
Copy link to clipboard
Copied
You can change
if (activeDocument.mode == DocumentMode.RGB) {
to
if (activeDocument.mode == DocumentMode.RGB || activeDocument.mode == DocumentMode.CMYK) {
Copy link to clipboard
Copied
Thank you so much
Copy link to clipboard
Copied
I believe I did what you described on Windows 10 + PS 21.1.1 I had no problem with the updated script. Fill Later withe the Alpha Late as mas ere added. Where the layers gets added depends on the current target when the script is run. If there are no alpha channels the script adds nothing and the is no error.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
With my test 0 was not a problem that would have been the RGB channel. with my test m when through 0-6 where 4 5 6 were alpha channels a b c. All code for m was in a Try Catch? If 0 was bad no error should be shown ? On my system 0, 1, 2, and 3 failed before "if (channelDesc.hasKey(stringIDToTypeID('alphaChannelOptions')) == true) {"