Copy link to clipboard
Copied
Hello,
I am looking for a script that can locate and delete all black layers in PS.
I don't know how to write Javascript, and I can't find any thread explaining how to do this.
I am looking for something that is similar to "Delete All Empty Layers" script, but that finds black layers instead.
Thank you for taking your time,
Tsu-tey
sTT = stringIDToTypeID; function tggl() {
(ref = new ActionReference()).putIdentifier(sTT('layer'), idntfr);
(lst = new ActionList()).putReference(ref); (dsc = new ActionDescriptor())
.putList(sTT('null'), lst), dsc.putBoolean(sTT('toggleOptionsPalette'), true)
executeAction(sTT('show'), dsc)
}
lrs = [].slice.call((aD = activeDocument).artLayers)
wh = aD.width * aD.height; while(lrs.length)
idntfr = (shft = lrs.shift()).id, tggl(),
blck = aD.histogram[0] == wh,
tggl(), blck && shft.rem
...
Give an example. Upload your PSD file.
Noticed that scripts (mine and yours) remove the black layer if there is one RGB pixel (0,0,1) in it, which is wrong. Corrected my script
// important, the active layer must not have to be a group.
var inv = false; // depends on channels settings. true = masked areas, false = selected areas. check what you have.
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("count"));
r.putEnumerated(stringIDToTypeID("lay
...
Copy link to clipboard
Copied
This works perfectly for me.
Copy link to clipboard
Copied
Thank you!