Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Script that finds and removes all black layers.

Explorer ,
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.

 

Layerstack.JPG

 

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

Views

318

Likes

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 2 Correct answers

Adobe Community Professional , 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...

Likes

Translate

Translate
Adobe Community Professional , 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...

Likes

Translate

Translate
Explorer ,
Jul 02, 2021 Jul 02, 2021

Copy link to clipboard

Copied

This works perfectly for me.

Likes

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
Explorer ,
Jul 02, 2021 Jul 02, 2021

Copy link to clipboard

Copied

Thank you!

Likes

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
    • 1
    • 2