返回

新闻详情

PS高端教程:在PS中用脚本语言来处理图片步骤八


来源:兰州天琥设计培训学校时间:2019/1/11 14:24:38

如下我总结了目前所有的代码,包括关于绿色通道和蓝色通道颜色值的校验:

open(File(openDialog()));

var docRef_1 = activeDocument;

docRef_1.backgroundLayer.duplicate();

var white = new SolidColor();

white.rgb[“hexValue”] = “ffffff”;

var black = new SolidColor();

black.rgb[“hexValue”] = “000000”;

foregroundColor = black;

backgroundColor = white;

docRef_1.selection.selectAll();

docRef_1.selection.fill(white);

docRef_1.selection.deselect();

docRef_1.layers[0].duplicate();

docRef_1.activeLayer = docRef_1.layers[0];

docRef_1.activeLayer.applyAverage();

for (RLevel = 0; RLevel <= 255; RLevel ++)

{ if (docRef_1.channels[0].histogram[RLevel]) { break; } }

for (GLevel = 0; GLevel <= 255; GLevel ++)

{ if (docRef_1.channels

.histogram[GLevel]) { break; } }

for (BLevel = 0; BLevel <= 255; BLevel ++)

{ if (docRef_1.channels

.histogram[BLevel]) { break; } }

(译者注:channels

、channels

和channels

分别是指红、绿、蓝颜色通道)

现在我们来检验最后一段代码的可行性,我们用一个弹出框来显示RGB的值。在以上代码片段结尾处添加如下代码:

alert(RLevel + “, ” + GLevel + “, ” + BLevel)

运行脚本,该弹框中应该会出现RGB的值,可以通过双击前景色切换到取色工具进行验证。如果颜色匹配就删掉这行代码,如果不匹配或者运行错误的话仔细检查或者直接复制以上代码重复尝试。


上一篇:PS高端教程:在PS中用脚本语言来处理图片步骤七

下一篇:PS高端教程:在PS中用脚本语言来处理图片步骤九

  咨询老师  拨打电话  网上报名