向图层添加矢量蒙版?

发布于 2024-12-02 15:32:42 字数 852 浏览 3 评论 0原文

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

// 如何将蒙版设置为蒙版???

谢谢 !

i'd like to know how to add a vector mask in photoshop to a given layer with photoshop sript (.jsx)?

I m not 100% sure what i want is called "vector mask" in photoshop.
I've got a picture and a mask in black and white, i'd like to automaticly add the mask to the image so we can only see what is under the white region.
Under the black region must be transparent pixel.
this must be simple but i can't find anything on the online doc...

here is what i did so far...

        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()

// how to set the mask as a mask????

Thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流年已逝 2024-12-09 15:32:42

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

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 );
}

You don't want vector mask; you want layer masks. Here's a function that I normally use. It'll put a layer mask on a layer with a selection. It won't work on a empty layer, however

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 );
}
陌路终见情 2024-12-09 15:32:42

我不确定如何通过脚本实现此目的,但要将矢量蒙版添加到图层,您必须:

  1. 绘制矢量路径(出现在“路径”窗口中)
  2. 让路径处于活动状态(选定)
  3. 转到“图层”菜单,“矢量”掩码、当前路径

I'm not sure how to make this via script, but to add a vector mask to a layer you have to:

  1. Draw a vector path (appears in the Paths window)
  2. Have the path active (selected)
  3. Go to the Layer menu, Vector Mask, Current Path
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文