Remove Empty channel
Dear all,
Is there any scripting to remove Empty channel from the Channel palette.
Dear all,
Is there any scripting to remove Empty channel from the Channel palette.
Here is an example for RGB or CMYK documents.
//Only RGB or CMYK documents
main();
function main(){
if(!documents.length) return;
var doc = activeDocument;
var PixCount =doc.width.as('px') * doc.height.as('px');
var CH=[];
var ChCount =0;
if(doc.mode == DocumentMode.RGB) ChCount =3;
if(doc.mode == DocumentMode.CMYK) ChCount =4;
if(ChCount == 0) return;
for(var a = ChCount;a<doc.channels.length;a++){
CH.push(doc.channels.name);
}
for(var a in CH){
doc.channels[CH].visible=true;
//if (doc.channels[CH].histogram[0] == PixCount)doc.channels[CH].remove(); //Black Channel
if (doc.channels[CH].histogram[255] == PixCount)doc.channels[CH].remove();//White Channel
else doc.channels[CH].visible=false;
}
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.