55 lines
2.0 KiB
JavaScript
55 lines
2.0 KiB
JavaScript
|
|
// 找到图层组后,显示文件夹选择框
|
|
var 文件夹 = Folder.selectDialog("请选择要打开文件的文件夹");
|
|
|
|
if (文件夹) {
|
|
var 文件列表 = 文件夹.getFiles();
|
|
for (var i = 0; i < 文件列表.length; i++) {
|
|
var 文件 = 文件列表[i];
|
|
// 确保文件是图像文件
|
|
if (文件 instanceof File && 文件.name.match(/\.(jpg|jpeg|png|gif|psd)$/i)) {
|
|
原始文档 = app.activeDocument;
|
|
app.open(文件);
|
|
图像大小();
|
|
预设图案(当前文档名称);
|
|
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
|
app.activeDocument =原始文档;
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function 图像大小() //图像大小
|
|
{
|
|
|
|
var d = new ActionDescriptor();
|
|
d.putUnitDouble(stringIDToTypeID("resolution"), stringIDToTypeID("densityUnit"), 200);
|
|
d.putBoolean(stringIDToTypeID("scaleStyles"), true);
|
|
d.putBoolean(stringIDToTypeID("constrainProportions"), true);
|
|
d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
|
executeAction(stringIDToTypeID("imageSize"), d, DialogModes.NO);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function 预设图案(当前文档名称) //
|
|
{
|
|
|
|
var d = new ActionDescriptor();
|
|
var r = new ActionReference();
|
|
r.putClass(stringIDToTypeID("pattern"));
|
|
d.putReference(stringIDToTypeID("null"), r);
|
|
var r1 = new ActionReference();
|
|
r1.putProperty(stringIDToTypeID("property"), stringIDToTypeID("selection"));
|
|
r1.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
|
d.putReference(stringIDToTypeID("using"), r1);
|
|
d.putString(stringIDToTypeID("name"), 当前文档名称);
|
|
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
|
|
|
} |