我需要做一个选项,当运行ps脚本时,我可以选择脚本将做什么。
例如:当我运行脚本时,我想要得到三个选项:调整大小,转换为sRGB或删除背景。
我似乎找不到任何这样的例子。
我试着找一些例子。然而,互联网上到处都是如何用javascript和HTML做到这一点的例子。但是我需要它来ps…
Photoshop代码没有很好的文档,Photoshop UI代码也没有很好的文档,尽管这里有文档(虽然没有更新)
然而…有一个网站可以让你轻松地构建Photoshop UI元素:scriptui.joonas.me这就是我所做的。
然后就是连接下拉选择来启动图像处理的问题了。
var dlg = new Window("dialog");
dlg.text = "Do that thing!";
dlg.orientation = "column";
dlg.alignChildren = ["center","top"];
dlg.spacing = 10;
dlg.margins = 16;
var statictext1 = dlg.add("statictext", undefined, undefined, {name: "statictext1"});
statictext1.text = "Do something";
var dropdown1_array = ["Resize","Convert to sRGB","Remove background"];
var dropdown1 = dlg.add("dropdownlist", undefined, undefined, {name: "dropdown1", items: dropdown1_array});
dropdown1.selection = 0;
dropdown1.preferredSize.width = 150;
// GROUP
var group1 = dlg.add("group", undefined, {name: "group1"});
group1.orientation = "row";
group1.alignChildren = ["left","center"];
group1.spacing = 10;
group1.margins = 0;
var button1 = group1.add("button", undefined, undefined, {name: "button1"});
button1.text = "OK";
button1.preferredSize.width = 70;
var button2 = group1.add("button", undefined, undefined, {name: "button2"});
button2.text = "Cancel";
button2.preferredSize.width = 70;
var myReturn = dlg.show(); // Show the dialog
if (myReturn == 1) // if user clicked Okay
{
// process the image here
var thingToDo = dropdown1.selection; // dropdown value
alert(thingToDo);
}