gpt4 book ai didi

javascript - 向图层添加矢量蒙版?

转载 作者:行者123 更新时间:2023-11-28 10:12:14 26 4
gpt4 key购买 nike

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

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

谢谢!

最佳答案

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

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

关于javascript - 向图层添加矢量蒙版?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7281696/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com