向图层添加矢量蒙版?

时间:2011-09-02 09:43:16

标签: javascript photoshop photoshop-script

我想知道如何使用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()

//如何将面具设置为面具????

谢谢!

2 个答案:

答案 0 :(得分:0)

我不知道如何通过脚本制作这个,但是要向你需要的图层添加矢量蒙版:

  1. 绘制矢量路径(显示在“路径”窗口中)
  2. 让路径处于活动状态(已选择)
  3. 转到图层菜单,矢量蒙版,当前路径

答案 1 :(得分: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 );
}