Question
Delete empty masks - Layer Masks, Vector Masks, and Filter Masks
I'm looking for a way to detect and delete empty Layer Masks and Filter Masks.
Layers and Layer Sets have two properties that make this easy to detect for Vector Masks.
Properties:
hasVectorMask
vectorMaskEmpty
Is there a way to detect empty Layer Masks and empty Filter Masks?
If it's possible to get the bounds of Layer Masks and Filter Masks that could lead to a solution.
This works for Vector Masks:
var actionReference = new ActionReference();
actionReference.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var actionDescriptor = executeActionGet(actionReference);
var hasVectorMask = actionDescriptor.getBoolean(stringIDToTypeID("hasVectorMask"));
var vectorMaskEmpty = actionDescriptor.getBoolean(stringIDToTypeID("vectorMaskEmpty"));
if (hasVectorMask && vectorMaskEmpty) {
var iddelete = stringIDToTypeID("delete");
var desc8 = new ActionDescriptor();
var idnull = stringIDToTypeID("null");
var ref7 = new ActionReference();
var idpath = stringIDToTypeID("path");
var idpath = stringIDToTypeID("path");
var idvectorMask = stringIDToTypeID("vectorMask");
ref7.putEnumerated(idpath, idpath, idvectorMask);
var idlayer = stringIDToTypeID("layer");
var idordinal = stringIDToTypeID("ordinal");
var idtargetEnum = stringIDToTypeID("targetEnum");
ref7.putEnumerated(idlayer, idordinal, idtargetEnum);
desc8.putReference(idnull, ref7);
executeAction(iddelete, desc8, DialogModes.NO);
}
