How to identify clipping masks in Photoshop using

2019-09-09 20:40发布

I've currently butchered a script I was reading that loops through a list of layers, and then looks for layers with a certain name (3/2, 4/3 etc). The next step is to check for layer masks that are clipped to the base layer, and merge them to it. I've read through the reference docs, and can't find anything about identifying clipping masks. I've attached an image as an example of how the document is structured.

enter image description here

And here is the code I have so far:

var doc = app.activeDocument  
var ratios = ["1/1", "4/3", "3/4", "3/2", "2/3", "16/9", "9/3", "7/2", "11/5"];  

for (var i = 0, il = doc.layers.length; i < il; i++) {  
    var curLayer = doc.layers[i];  
    for (var j = 0, jl = ratios.length; j < jl; j++) {  
        if (curLayer.name == ratios[j]) {  
            alert(curLayer.name); 
            // Check for clipping masks attached to this layer
        }
    }  
}  

I am using Photoshop CS5. Thanks!

1条回答
我命由我不由天
2楼-- · 2019-09-09 21:11

I ended up working out another way to do it. I instead grouped the layers into a layerset, and exported them out of the document that way. For those that would like to see it, have a look here:

https://gist.github.com/BeauAgst/4da366b933cc75a0606a

查看更多
登录 后发表回答