自动保存适用于 Windows 但不适用于 Mac
Auto-saving works on Windows but not on a Mac
我按照此线程 (Saving without dialog window) 中提供的代码将 overwrite/save 图像设为 PNG,而没有 'Save as..' 对话框。它在我的 Windows PC 上运行良好。但是我把脚本文件传给了我的搭档,他用了一个Mac,它不起作用。这是他给我看的错误:
这是脚本:
// 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.
// Save the file.
var opts = new ExportOptionsSaveForWeb();
opts.PNG8 = false;
opts.transparency = true;
opts.interlaced = false;
opts.quality = 100;
opts.includeProfile = false;
opts.format = SaveDocumentType.PNG;
activeDocument.exportDocument(Path, ExportType.SAVEFORWEB, opts);
doc.close(SaveOptions.DONOTSAVECHANGES);
使用 Photoshop 通常很难说出为什么一个 hacky 的东西在一个 OS 上有效,但在另一个上却不起作用,我建议只给 .exportDocument()
一个完整的路径名:
activeDocument.exportDocument(new File(Path + "/" + doc.name.replace(/\.[^.]+$/g, ".png")), ExportType.SAVEFORWEB, opts);
我按照此线程 (Saving without dialog window) 中提供的代码将 overwrite/save 图像设为 PNG,而没有 'Save as..' 对话框。它在我的 Windows PC 上运行良好。但是我把脚本文件传给了我的搭档,他用了一个Mac,它不起作用。这是他给我看的错误:
这是脚本:
// 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.
// Save the file.
var opts = new ExportOptionsSaveForWeb();
opts.PNG8 = false;
opts.transparency = true;
opts.interlaced = false;
opts.quality = 100;
opts.includeProfile = false;
opts.format = SaveDocumentType.PNG;
activeDocument.exportDocument(Path, ExportType.SAVEFORWEB, opts);
doc.close(SaveOptions.DONOTSAVECHANGES);
使用 Photoshop 通常很难说出为什么一个 hacky 的东西在一个 OS 上有效,但在另一个上却不起作用,我建议只给 .exportDocument()
一个完整的路径名:
activeDocument.exportDocument(new File(Path + "/" + doc.name.replace(/\.[^.]+$/g, ".png")), ExportType.SAVEFORWEB, opts);