我在Photoshop中有1个组,其中有多个图像默认情况下隐藏,除了第一个图像,我希望逐个显示除第一个图像之外的每个图像然后用合并的第一层使用导出图像在Photoshop中打开和关闭多个图层脚本
注意导出为图片:请看到的截图Layer
有人能指出我的方向是否有可能与脚本或采取任何行动?
我从来没有在Photoshop中脚本,但试图找出我自己的。
我在Photoshop中有1个组,其中有多个图像默认情况下隐藏,除了第一个图像,我希望逐个显示除第一个图像之外的每个图像然后用合并的第一层使用导出图像在Photoshop中打开和关闭多个图层脚本
注意导出为图片:请看到的截图Layer
有人能指出我的方向是否有可能与脚本或采取任何行动?
我从来没有在Photoshop中脚本,但试图找出我自己的。
编辑完整的文章,但此脚本涵盖了原始脚本(仅适用于单层组)的可用性,并且也将其自身扩展到所有图层组。
脚本从文件中的每个图层组中取出图层,并遍历所有图层,除了给定组中的第一个图层打开和关闭以进行保存。对于给定的组迭代,每个组中的第一层始终可见。以PNG格式导出,但您可以调整所需的任何内容 - 导出选项,路径,文件名等。为CS6创建,但应该适用于任何版本,只需查看它。
您可能需要的更多信息在参考手册中。只为Google为Photoshop CS6/CC Javascript参考。
下面的代码,只需使用记事本复制粘贴,并保存为jsx文件。您可以使用ExtendScript Toolkit进行测试(它已经与Adobe一起安装,您只需要找到它)。如果它按预期工作,请将文件放置在Adobe \ Adobe Photoshop CS6(64位)\ Presets \ Scripts文件夹中,重新启动Photoshop并通过文件>脚本菜单访问该脚本。如果需要多次重复执行此操作,则还可以将键盘快捷键绑定到它。干杯!
#target Photoshop
if (documents.length == 0) {
alert("nothing opened");
} else {
// start
//setup
var file = app.activeDocument;
var groupsAmount = file.layerSets.length; // get the layer groups
// iterate through groups
for (var k=0; k < groupsAmount; k++) {
hideAllLayers();
var images = file.layerSets[k].layers; // get the layers from the given group
file.layerSets[k].visible = true;
images[0].visible = true; // show the first layer in this group
// begin "i" from 1 to start from the 2nd layer
for (var i=1; i < images.length; i++) {
images[i].visible = true;
exportimage(images[i].name);
images[i].visible = false;
}
}
// function used to export image (adjust as you want accoring to the manual)
function exportimage(name){
var options = new ExportOptionsSaveForWeb();
options.format = SaveDocumentType.PNG;
options.PNG8 = false;
options.transparency = true;
options.optimized = true;
// adjust path & name
file.exportDocument(File(file.path+"/"+name+".png"),ExportType.SAVEFORWEB, options);
}
// function to hide all layers
// simplified version of http://morris-photographics.com/photoshop/scripts/downloads/Hide%20All%20Layers%202-1-0.jsx
function hideAllLayers() {
var ref = new ActionReference();
ref.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
var desc = new ActionDescriptor();
desc.putReference(cTID('null'), ref);
executeAction(sTID('selectAllLayers'), desc, DialogModes.NO);
var ref = new ActionReference();
ref.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
var list = new ActionList();
list.putReference(ref);
var desc = new ActionDescriptor();
desc.putList(cTID('null'), list);
executeAction(cTID('Hd '), desc, DialogModes.NO);
}
function cTID(s) {return app.charIDToTypeID(s);}
function sTID(s) {return app.stringIDToTypeID(s);}
//end
}
它是完美的工作!因为我想但你能帮助我,如果在同一个文件中有多个文件夹,我想在单个文件夹上应用相同的东西? –
@LuicePhillips对答复时间表示歉意,但没时间。这是扩展版本 - 完全相同,但涵盖所有组。请享用! –
感谢您的答复,我已经尝试更新的脚本,它的工作太棒了..再次感谢您的帮助 –