How to identify clipping masks in Photoshop using JavaScript

江枫思渺然 提交于 2019-12-11 20:37:13

问题


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.

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:


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



来源:https://stackoverflow.com/questions/35057122/how-to-identify-clipping-masks-in-photoshop-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!