Hi - i m learning javascript and trying to create a little script that would help me automate how I export files from Phothoshop.
Atm I am stuck on one aspect :
I want to loop through all layers in my active doc and check if a layer mask is applied.
I have been through the photoshop documentation, but i can't not find infos regarding layer masks in Ps in javascript.
This is the little bit of code i have at the momemt just to check if there is layer applied on a selected layer
var activeDoc = app.activeDocument;
var selectedLayer = doc.activeLayer;
if (selectedLayer.hasMask){
alert(selectedLayer.name + " has a mask.")
}
else {
alert(selectedLayer.name + " has no mask.")
}
This script returns "has no mask" - but my selected layer does have a layer mask applied.
Thank for the help!
check if layer has layer mask
Re: check if layer has layer mask
Code: Select all
sTT = stringIDToTypeID;
(ref = new ActionReference()).putEnumerated
(sTT('layer'), sTT('ordinal'), sTT('targetEnum'))
alert(executeActionGet(ref).getBoolean(sTT('hasUserMask')))
-
- Posts: 2
- Joined: Fri Nov 29, 2024 5:37 pm
Re: check if layer has layer mask
It worked! Thanks