exportDocument() '目标文件夹不存在'错误
我正在尝试在 Photoshop 中制作一个脚本,该脚本将修改一些图层并将它们导出为 PNG 图像。我从其他地方复制了以下代码:
function SavePNG(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = true;
pngOpts.quality = 100;
activeDocument.exportDocument(saveFile,ExportType.SAVEFORWEB,pngOpts);
}
该函数将photoshop的活动文档导出到saveFile参数指定的文件中。
它可以很好地处理“C:\images\result.png”等简单路径,但是当尝试使用“~/Desktop/”等不同路径或具有某些特殊字符的路径时,文件不会导出,并且“目标文件夹不会”存在”错误消息出现。
知道如何解决吗?
I'm trying to make a script in photoshop that will modify some layers and than export them as a PNG image. I've copied the following code from another place:
function SavePNG(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = true;
pngOpts.quality = 100;
activeDocument.exportDocument(saveFile,ExportType.SAVEFORWEB,pngOpts);
}
The function export the active document of photoshop to the file specified by the saveFile parameter.
It's working fine with simple paths like "C:\images\result.png" but when trying with different paths like "~/Desktop/" or paths with some special characters the file isn't exported, and a "destination folder does not exist" error message appears.
Any idea how can I solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我不确定为什么会发生这种情况,但您可以尝试以下修改:
它将文件导出到临时文件中,然后重命名&将其移动到请求的路径,应该可以解决路径问题。
Well, I'm not sure why this is occur but you could try the following modification:
it'll export the file into a temporary file and then rename & move it to the requested path, should solve the path problem.
exportDocument 需要完整的文件名,而不是文件夹路径。
这有效:
这不起作用并给出“目标文件夹不存在”错误消息:
exportDocument expects a full file name, not a folder path.
This works:
This doesn't work and gives the 'destination folder does not exist' error message:
对于遇到此错误并且未使用
photoshop-script
的人。该错误可能未绑定到目标文件夹,但由于用于导出步骤的文件夹被删除而发生。因此,要么
For people having this error and not using
photoshop-script
.The error might be unbound to the destination folder, but occurs because the folder, which was used for the export step, is deleted. So either