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

Convert all alpha channels into layers.

Community Beginner ,
May 03, 2020 May 03, 2020

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

TOPICS
Actions and scripting , Windows

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

correct answers 1 Correct answer

Community Expert , May 06, 2020 May 06, 2020

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 () {
/
...

Votes

Translate

Translate
Adobe
Community Expert ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

Looks good

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
Contributor ,
Jan 09, 2023 Jan 09, 2023

Copy link to clipboard

Copied

Hello!! Can this work with CMYK as well? Thanks!

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 ,
Jan 10, 2023 Jan 10, 2023

Copy link to clipboard

Copied

You can change  

if (activeDocument.mode == DocumentMode.RGB) {

to 

if (activeDocument.mode == DocumentMode.RGB || activeDocument.mode == DocumentMode.CMYK) {

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
Contributor ,
Jan 10, 2023 Jan 10, 2023

Copy link to clipboard

Copied

LATEST

Thank you so 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
Community Expert ,
May 04, 2020 May 04, 2020

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.

Capture.jpg

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
People's Champ ,
May 04, 2020 May 04, 2020

Copy link to clipboard

Copied

>>>I did the same what I described and used new version of script and I'm getting same error.
 
What kind of error?
Try
for (var m = 1; m <= theNumber; m ++) {

Zero index is not valid.
 

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 ,
May 04, 2020 May 04, 2020

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) {"

image.png

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