我有一个保存在某个位置的主文档。这个主文件有一个大精灵。在运行脚本时,会使用各种模式的精灵创建多个新文档。我想将这些多个新文档另存为PNG,而无需访问“另存为...”对话框并关闭它们。
// ==============================================================
// This code is run on the master document to get the Path.
// The saved directory location of the main master document.
Path = doc.path; // If the document is new there is no doc.path. Error is shown.
// ==============================================================
// ==============================================================
// This code is run at the end of the multiple new documents that's created.
// Save the file.
var Name = doc.name.replace(/\.[^\.]+$/, '');
var Suffix = "";
var saveFile = File(Path + "/" + Name + Suffix + ".png");
if (saveFile.exists) saveFile.remove();
var pngOptions = new PNGSaveOptions();
pngOptions.compression = 0;
pngOptions.interlaced = false;
activeDocument.saveAs(saveFile, pngOptions, false, Extension.LOWERCASE);
doc.close(SaveOptions.DONOTSAVECHANGES);
// ==============================================================
答案 0 :(得分:2)
即使您找到了解决方案,我也想回答您最初的问题:如何隐藏对话框-这有时很有用。您可以通过更改Photoshop app.displayDialogs
属性来实现:
app.displayDialogs = DialogModes.NO; // no dialogs will be displayed
// your code
app.displayDialogs = DialogModes.ERROR; // default value
在您明确希望显示UI的情况下,它也可以是DialogModes.ALL
。