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

Convert all alpha channels into layers.

Community Beginner ,
May 03, 2020 May 03, 2020

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
4.2K
Translate
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 () {
/
...
Translate
Adobe
Community Expert ,
May 15, 2020 May 15, 2020

Looks good

JJMack
Translate
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

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

Translate
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

You can change  

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

to 

if (activeDocument.mode == DocumentMode.RGB || activeDocument.mode == DocumentMode.CMYK) {
Translate
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
LATEST

Thank you so much

Translate
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

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
Translate
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
>>>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.
 
Translate
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

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
Translate
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