Photoshop Javascript脚本保存和关闭文档 [英] Photoshop Javascript scripting saving and closing document

查看:124
本文介绍了Photoshop Javascript脚本保存和关闭文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,我在保存时遇到了麻烦; 我正在使用Photoshop CS5.1(如果确实是问题的原因)

I'm having trouble saving for some reason; I'm using Photoshop CS5.1 (if that really is the cause of the issue)

error 8800: General Photoshop error occurred. 
This functionality may not be available in this version of Photoshop.
Could not save a copy as C:\...\Temp001.jpeg0011338281522" 
because the file could not be found


var thistimestamp = Math.round(new Date().getTime() / 1000);
saveFile = new File( "/Users/Barny/My Pictures/Temp001" +thistimestamp+ ".jpeg" )
saveOptions = new JPEGSaveOptions();
saveOptions.embedColorProfile = true;
saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
saveOptions.matte = MatteType.NONE;
saveOptions.quality = 9;
app.activeDocument.saveAs(saveFile, saveOptions, true,Extension.LOWERCASE);

我想要保存并关闭脚本,但是我一直收到此错误.我正在使用Photoshop CS5.1(如果确实是问题的原因)

I'd like the script to save and close, but I keep getting this error. I'm using Photoshop CS5.1 (if that really is the cause of the issue)

推荐答案

在保存时收到错误General Photoshop error时,通常表示保存路径存在问题. Photoshop尝试将其保存到不存在的位置.假设文件夹C:/Users/Barney/Pictures/Temp001存在,此方法有效:

When you get the error General Photoshop error while saving it usually means a problem with the save path. Photoshop is trying to save to a location that doesn't exist. This works assuming the folder C:/Users/Barney/Pictures/Temp001 exists:

var thistimestamp = Math.round(new Date().getTime() / 1000);
saveFile = new File( "c:/Users/Barney/Pictures/Temp001/" +thistimestamp)
saveOptions = new JPEGSaveOptions();
saveOptions.embedColorProfile = true;
saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
saveOptions.matte = MatteType.NONE;
saveOptions.quality = 9;

app.activeDocument.saveAs(saveFile, saveOptions, true,Extension.LOWERCASE);

我所做的唯一更改是对路径字符串saveFile = new File("C:/Users/Barney/Pictures/Temp001/" + thistimestamp)的注意.请注意,我添加了C:使其成为绝对路径,并在Temp001之后添加了/来指定这是一个文件夹,而不是最终目录的一部分文档名称. My Pictures实际上应该是Pictures(我的图片只是一个别名),这是从地址栏中复制地址后得到的.我也删除了+ ".jpeg",因为photoshop会为您处理文件扩展名.

The only changes I made were to to the path string saveFile = new File("C:/Users/Barney/Pictures/Temp001/" + thistimestamp) Notice I added the C: to make it an absolute path and added a / after Temp001 to specify this is a folder and not part of the final file name. My Pictures should actually be Pictures (my pictures is just an alias), which is what you get if you copy the address from the address bar. Also I removed the + ".jpeg" because photoshop takes care of the file extension for you.

如果要创建新文件夹,则必须使用Folder对象:

If you're trying to create a new folder you have to use the Folder object:

var myfolder = new Folder("c:/Users/Barney/Pictures/Temp001/");
myfolder.create();

这篇关于Photoshop Javascript脚本保存和关闭文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆