此脚本采用最后应用的过滤器,并在所有选定的图层和蒙版上重复它。(它旨在避免为了批量应用过滤器而将图层折叠成智能对象)。
但是,其中有一个我无法弄清楚的错误:它对于高斯模糊之类的东西效果很好,但对于液化,它会在历史记录中记录已应用过滤器,但图层保持不变。
重现步骤:1.模糊图层 1。2.选择图层 2(蒙版)和 3(未蒙版) 3.运行脚本4.重复 1-3,但使用液化而不是模糊。
#target photoshop
var defaultRulerUnits = preferences.rulerUnits; preferences.rulerUnits = Units.PIXELS;
var doc = app.activeDocument;
var layers = doc.layers;
var typeArray = new Array ();
var isim = new Array();
cTID = function(s) { return app.charIDToTypeID(s); }; sTID = function(s) { return app.stringIDToTypeID(s); };
function repeatlastfilter() {
runMenuItem(cTID("LstF"), true);
}
function checklayermask() {
try {
Select_Layermask();
}
catch (err) { return }
repeatlastfilter();
Select_Original_Layer();
}
// MAIN
function main()
{
app.bringToFront();
var SelectedLayers = getSelectedLayers();
for (var i = 0; i < SelectedLayers.length; i++)
{
doc.activeLayer = SelectedLayers[i];
isim[i] = SelectedLayers[i].name;
//selectlayer(isim[i]);
//alert (isim[i]);
repeatlastfilter();
checklayermask();
//doAction(DDActions.selection.text, DDActionSet.selection.text);
}
}
// SELECT ORIGINAL LAYER
function Select_Original_Layer(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Chnl'), cTID('Chnl'), sTID("RGB"));
desc1.putReference(cTID('null'), ref1);
desc1.putBoolean(cTID('MkVs'), false);
executeAction(cTID('slct'), desc1, dialogMode);
};
// SELECT LAYER MASK
function Select_Layermask(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Chnl'), cTID('Chnl'), cTID('Msk '));
desc1.putReference(cTID('null'), ref1);
desc1.putBoolean(cTID('MkVs'), false);
executeAction(cTID('slct'), desc1, dialogMode);
};
// GET SELECTED LAYERS
function getSelectedLayers()
{
var resultLayers=new Array();
try{
var descGrp = new ActionDescriptor();
var refGrp = new ActionReference();
refGrp.putEnumerated(cTID( "Lyr " ),cTID( "Ordn" ),cTID( "Trgt" ));
descGrp.putReference(cTID( "null" ), refGrp );
executeAction( sTID( "groupLayersEvent" ), descGrp, DialogModes.NO );
for (var ix=0;ix<app.activeDocument.activeLayer.layers.length;ix++){resultLayers.push(app.activeDocument.activeLayer.layers[ix])}
var desc5 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnumerated( cTID( "HstS" ), cTID( "Ordn" ), cTID( "Prvs" ) );
desc5.putReference( cTID( "null" ), ref2 );
executeAction( cTID( "slct" ), desc5, DialogModes.NO );
} catch (err) { }
return resultLayers;
}
main();