0
Participant
,
/t5/photoshop-ecosystem-discussions/script-that-finds-and-removes-all-black-layers/td-p/12154125
Jul 02, 2021
Jul 02, 2021
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
TOPICS
Actions and scripting
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
2 Correct answers
LEGEND
,
Jul 02, 2021
Jul 02, 2021
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
...
People's Champ
,
Jul 03, 2021
Jul 03, 2021
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
...
Explore related tutorials & articles
Tsu-tey
AUTHOR
Participant
,
/t5/photoshop-ecosystem-discussions/script-that-finds-and-removes-all-black-layers/m-p/12154263#M558888
Jul 02, 2021
Jul 02, 2021
Copy link to clipboard
Copied
This works perfectly for me.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Tsu-tey
AUTHOR
Participant
,
/t5/photoshop-ecosystem-discussions/script-that-finds-and-removes-all-black-layers/m-p/12154264#M558889
Jul 02, 2021
Jul 02, 2021
Copy link to clipboard
Copied
Thank you!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more


-
- 1
- 2