如何使用 Photoshop 脚本修改混合选项?

发布于 2024-12-09 02:08:41 字数 116 浏览 1 评论 0原文

我有一个 Photoshop Javascript 脚本,可以在不同的图层之间循环,我想根据图层的名称为每个图层提供不同的外发光。

有人可以举例说明如何以编程方式更改 ArtLayer 类的混合选项吗?

I have a Photoshop Javascript script that cycles through different layers and I want to give a different outer glow to each layer based on the name of the layer.

Can someone give an example on how to change the blending options of an ArtLayer class programatically?

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

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

发布评论

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

评论(1

梦回旧景 2024-12-16 02:08:41

不幸的是,没有简单的方法来添加图层样式。

.applyStyle("Puzzle (Image)") 但其他样式未包含在文档中,并且我在任何地方都找不到其他样式。

所以你必须使用解决方法(棘手且复杂的过程)。

第 1 步(如果您想要现成的解决方案,请跳过)

首先,您需要执行操作(向图层添加外发光),然后转换为 .jsx 脚本。

您需要使用此脚本进行转换:
http://ps-scripts .cvs.sourceforge.net/viewvc/ps-scripts/xtools/apps/ActionToJavascript.jsx?revision=1.29

从 Ps 或从运行ExtendScript,选择您的操作并保存。

步骤 2

在你新创建的脚本中,你会看到可怕且不可读的代码,它会立即工作,但是如果你想使用不同的设置(颜色、不透明度、混合模式等),你需要创建函数。

这是干净的版本。

cTID = function(s){ return app.charIDToTypeID(s); };
sTID = function(s){ return app.stringIDToTypeID(s); };
// Add Style: Glow
function addStyleGlow( R, G, B, blendingMode, opacity, spread, size ){
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Prpr'), cTID('Lefx'));
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(cTID('Scl '), cTID('#Prc'), 100);
// Glow color
var desc4 = new ActionDescriptor();
var rgb = new Array();
desc4.putDouble(cTID('Rd  '), R);
desc4.putDouble(cTID('Grn '), G);
desc4.putDouble(cTID('Bl  '), B);
// Blending mode of the effect
var desc3 = new ActionDescriptor();
desc3.putBoolean(cTID('enab'), true);
desc3.putEnumerated( cTID('Md  '), cTID('BlnM'), cTID(blendingMode) );
desc3.putObject(cTID('Clr '), sTID("RGBColor"), desc4);
// Opacity
desc3.putUnitDouble(cTID('Opct'), cTID('#Prc'), opacity);
desc3.putEnumerated(cTID('GlwT'), cTID('BETE'), cTID('SfBL'));
// Spread
desc3.putUnitDouble(cTID('Ckmt'), cTID('#Pxl'), spread);
// Size
desc3.putUnitDouble(cTID('blur'), cTID('#Pxl'), size);
// Noise
desc3.putUnitDouble(cTID('Nose'), cTID('#Prc'), 0);
// Quality: Jitter
desc3.putUnitDouble(cTID('ShdN'), cTID('#Prc'), 0);
desc3.putBoolean(cTID('AntA'), true);
var desc5 = new ActionDescriptor();
desc5.putString(cTID('Nm  '), "Linear");
desc3.putObject(cTID('TrnS'), cTID('ShpC'), desc5);
// Quality: Range
desc3.putUnitDouble(cTID('Inpr'), cTID('#Prc'), 50);
desc2.putObject(cTID('OrGl'), cTID('OrGl'), desc3);
desc1.putObject(cTID('T   '), cTID('Lefx'), desc2);
executeAction(cTID('setd'), desc1, DialogModes.NO);
}; // End of Add Style: Glow

步骤 3

您将需要另一个脚本文件来调用该函数,将其放在同一文件夹中(将“antoxa_myGlow.jsx”替换为您的脚本名称)。

//@include "antoxa_myGlow.jsx"
// R, G, B, blend mode, opacity, spread, size
addStyleGlow(255, 255, 54, 'Nrml', 75, 0, 5);

目前,如果您选择,它将仅适用于一个选定的层多层,它会给你错误。我还不知道如何将函数应用到多个选定的图层。

Unfortunately, there's no easy way to add layer styles.

There is .applyStyle("Puzzle (Image)") but other styles are not included in documentation, and I couldn't find other styles anywhere.

So you have to use workaround (tricky and complicated process).

Step 1 (Skip if you want ready solution)

First of all, you'll need to make action (add outer glow to layer) and then convert to .jsx script.

You need to use this script for conversion:
http://ps-scripts.cvs.sourceforge.net/viewvc/ps-scripts/xtools/apps/ActionToJavascript.jsx?revision=1.29

Run it from Ps or from ExtendScript, choose your action and save it.

Step 2

In your newly created script, you'll see horrible and unreadable code, it will work right away, however you'll need to make function if you want to use different settings (color, opacity, blend mode, etc).

Here's clean version.

cTID = function(s){ return app.charIDToTypeID(s); };
sTID = function(s){ return app.stringIDToTypeID(s); };
// Add Style: Glow
function addStyleGlow( R, G, B, blendingMode, opacity, spread, size ){
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Prpr'), cTID('Lefx'));
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(cTID('Scl '), cTID('#Prc'), 100);
// Glow color
var desc4 = new ActionDescriptor();
var rgb = new Array();
desc4.putDouble(cTID('Rd  '), R);
desc4.putDouble(cTID('Grn '), G);
desc4.putDouble(cTID('Bl  '), B);
// Blending mode of the effect
var desc3 = new ActionDescriptor();
desc3.putBoolean(cTID('enab'), true);
desc3.putEnumerated( cTID('Md  '), cTID('BlnM'), cTID(blendingMode) );
desc3.putObject(cTID('Clr '), sTID("RGBColor"), desc4);
// Opacity
desc3.putUnitDouble(cTID('Opct'), cTID('#Prc'), opacity);
desc3.putEnumerated(cTID('GlwT'), cTID('BETE'), cTID('SfBL'));
// Spread
desc3.putUnitDouble(cTID('Ckmt'), cTID('#Pxl'), spread);
// Size
desc3.putUnitDouble(cTID('blur'), cTID('#Pxl'), size);
// Noise
desc3.putUnitDouble(cTID('Nose'), cTID('#Prc'), 0);
// Quality: Jitter
desc3.putUnitDouble(cTID('ShdN'), cTID('#Prc'), 0);
desc3.putBoolean(cTID('AntA'), true);
var desc5 = new ActionDescriptor();
desc5.putString(cTID('Nm  '), "Linear");
desc3.putObject(cTID('TrnS'), cTID('ShpC'), desc5);
// Quality: Range
desc3.putUnitDouble(cTID('Inpr'), cTID('#Prc'), 50);
desc2.putObject(cTID('OrGl'), cTID('OrGl'), desc3);
desc1.putObject(cTID('T   '), cTID('Lefx'), desc2);
executeAction(cTID('setd'), desc1, DialogModes.NO);
}; // End of Add Style: Glow

Step 3

You will need another script file to call that function, place it in same folder (replace "antoxa_myGlow.jsx" with your script name)

//@include "antoxa_myGlow.jsx"
// R, G, B, blend mode, opacity, spread, size
addStyleGlow(255, 255, 54, 'Nrml', 75, 0, 5);

Currently it will work only with one selected layer, if you choose multiple layers, it will give you error. I don't know how to apply function to multiple selected layers yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文