I now want to modify it and have him execute this script for all my selected layers. How can I do this and need your help
Code: Select all
// 背景填充颜色
var colorRef = new SolidColor;
colorRef.rgb.red = 255;
colorRef.rgb.green = 255;
colorRef.rgb.blue = 255;
// 将以下设置为true以使背景透明。
var isTransparent = true;
// 将以下设置为true以使用图像作为背景
var isImageBg = true;
// 如果isImageBg设置为true,
// 则需要预先在Photoshop中打开背景图像
// 背景图像必须是活动文档
//-----------------------------------------------------------------------------------
// 检查是否选择使用图像作为背景
if (isImageBg) {
// 在变量中存储背景图像
var doc_bg = app.activeDocument;
}
// 现在将打开文件列表中的每个文件
// for (var a = 0; a < fileList.length; a++) {
// 在Photoshop中打开文件
// app.open(fileList[a]);
// 选择主体
var idautoCutout = stringIDToTypeID("autoCutout");
var desc01 = new ActionDescriptor();
var idsampleAllLayers = stringIDToTypeID("sampleAllLayers");
desc01.putBoolean(idsampleAllLayers, false);
try {
executeAction(idautoCutout, desc01, DialogModes.NO);
} catch (err) {}
// 反转选择
app.activeDocument.selection.invert();
// 现在背景已被选中。下一步是填充或清除选择。
if (isTransparent) {
// 使活动图层成为普通图层。
activeDocument.activeLayer.isBackgroundLayer = false;
// 使选择透明
app.activeDocument.selection.clear();
app.activeDocument.selection.clear();
} else {
app.activeDocument.selection.fill(colorRef);
}
// 取消选择
app.activeDocument.selection.deselect();