1

我想知道如何使用 photoshop sript (.jsx) 将 Photoshop 中的矢量蒙版添加到给定图层?

我不是 100% 确定我想要的东西在 Photoshop 中被称为“矢量蒙版”。我有一张黑白的图片和一个蒙版,我想自动将蒙版添加到图像中,这样我们只能看到白色区域下的内容。黑色区域下必须是透明像素。这一定很简单,但我在在线文档上找不到任何东西......

这是我到目前为止所做的......

        var f_image = File(imageAdress)
    open(f_image)

    var bgLayer = activeDocument.artLayers[0]
    bgLayer.isBackgroundLayer = false;


     var maskLayer = activeDocument.artLayers.add()
     maskLayer.name = "mask"

    open(File(maskAdress))
    // flatten the document so we get everything and then copy
    app.activeDocument.flatten()
    app.activeDocument.selection.selectAll()
    app.activeDocument.selection.copy()
    // don’t save anything we did
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES)
    app.activeDocument.paste()

// 如何将遮罩设置为遮罩???

谢谢 !

4

2 回答 2

0

我不知道如何通过脚本进行此操作,但要向图层添加矢量蒙版,您必须:

  1. 绘制矢量路径(出现在路径窗口中)
  2. 激活路径(选中)
  3. 转到图层菜单,矢量蒙版,当前路径
于 2011-09-07T14:38:49.797 回答
0

你不想要矢量蒙版;你想要图层蒙版。这是我通常使用的功能。它会在带有选区的图层上放置图层蒙版。但是,它不适用于空图层

makeMask()

// FUNCTION MAKE MASK
function makeMask()
{
  var id4556 = charIDToTypeID( "setd" );
  var desc983 = new ActionDescriptor();
  var id4557 = charIDToTypeID( "null" );
  var ref657 = new ActionReference();
  var id4558 = charIDToTypeID( "Chnl" );
  var id4559 = charIDToTypeID( "fsel" );
  ref657.putProperty( id4558, id4559 );
  desc983.putReference( id4557, ref657 );
  var id4560 = charIDToTypeID( "T   " );
  var ref658 = new ActionReference();
  var id4561 = charIDToTypeID( "Chnl" );
  var id4562 = charIDToTypeID( "Chnl" );
  var id4563 = charIDToTypeID( "Trsp" );
  ref658.putEnumerated( id4561, id4562, id4563 );
  desc983.putReference( id4560, ref658 );
  executeAction( id4556, desc983, DialogModes.NO );

  var id4564 = charIDToTypeID( "Mk  " );
  var desc984 = new ActionDescriptor();
  var id4565 = charIDToTypeID( "Nw  " );
  var id4566 = charIDToTypeID( "Chnl" );
  desc984.putClass( id4565, id4566 );
  var id4567 = charIDToTypeID( "At  " );
  var ref659 = new ActionReference();
  var id4568 = charIDToTypeID( "Chnl" );
  var id4569 = charIDToTypeID( "Chnl" );
  var id4570 = charIDToTypeID( "Msk " );
  ref659.putEnumerated( id4568, id4569, id4570 );
  desc984.putReference( id4567, ref659 );
  var id4571 = charIDToTypeID( "Usng" );
  var id4572 = charIDToTypeID( "UsrM" );
  var id4573 = charIDToTypeID( "RvlS" );
  desc984.putEnumerated( id4571, id4572, id4573 );
  executeAction( id4564, desc984, DialogModes.NO );
}
于 2012-11-15T15:02:24.420 回答