Skip to main content
Participant
August 22, 2016
Question

Remove White Mattes

  • August 22, 2016
  • 1 reply
  • 355 views

How to Remove White Mattes from all layers without creating an action? Using Javascript.

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
August 22, 2016

You may not be able too.  You could loop thorough all layers and set all normal layer blend if gray to remove all white or use the magic wand set to contiguous to select the layer background and clear it.  If the background is a solid color it would be cleared.  I can not think of a way to just select White Mattes.

JJMack
Participant
August 22, 2016

In that case I have saved an action named "Remove White Matte" and saved it in a action set named "Arijit". I am trying this script below, but it is only working on the layers outside the groups....inside the groups it is not affecting any layers...

var srcDoc = app.activeDocument;

var numOfLayers = srcDoc.layers.length;

for (var i = numOfLayers -1; i >= 0  ; i--)

    {    var layerName = srcDoc.layers.name;

        // check for groups

var a = srcDoc.layers.getByName(layerName);

            app.activeDocument.activeLayer = a;

        if (srcDoc.layers.typename == "ArtLayer")

            {

            app.doAction("Remove_White_Matte", "Arijit");

            }

    }

JJMack
Community Expert
Community Expert
August 22, 2016

What does the Action Do? A script can do the same thing an action can.   You do not have to even use get by name just loop through all layers and those that are normal layers  not smart objects, text, adjustment, background, etc layers do what the Action does. Smart Object layers background could be mask off.

#target photoshop

app.bringToFront();

if (!documents.length) { alert('There are no documents open.', 'No Document');}

else {processArtLayers(activeDocument);}

function processArtLayers(obj) {

    for( var i = obj.artLayers.length-1; 0 <= i; i--) {

         If  (obj.artLayers.kind = is the kind of layer you want to change) {

              change the layer;

              }

         }

    for( var i = obj.layerSets.length-1; 0 <= i; i--) {processArtLayers(obj.layerSets); } // Process Layer Set Layers

}

JJMack