使用actiondescriptor删除图层蒙版

时间:2019-02-11 21:33:39

标签: javascript photoshop mask layer extendscript

我一直试图弄清楚如何禁用或删除图层蒙版。我知道可以使用'RmvL'使用actiondescriptor的方法,但是到目前为止我还没有运气。

我正在使用app.activeDocument.paste(true)(是的,因为我将其粘贴到选择中),如果我可以通过使用其他方法绕过它,那么我可以一直跳过删除图层蒙版,因为通过使用true,Photoshop会自动应用图层面具。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

您为什么认为它是'RmvL'描述符? Scriptlistener为我们提供了'Dlt ' charID。它包装到一个函数中:

/**
 * deletes layer mask from active layer
 * @param  if apply is true, mask will be applied, if false — mask will be discarded
 * @return boolean
 */
function deleteMask(apply)
{
    if (apply == undefined) apply = false;
    try
    {
        var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putEnumerated(charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Msk '));
        desc.putReference(charIDToTypeID('null'), ref);
        desc.putBoolean(charIDToTypeID('Aply'), apply);
        executeAction(charIDToTypeID('Dlt '), desc, DialogModes.NO);
        return true
    }
    catch (e)
    {
        return false
    }
};
相关问题