最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Photoshop Javascript scripting saving and closing document - Stack Overflow

programmeradmin1浏览0评论

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);

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)

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);

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)

Share Improve this question edited May 29, 2012 at 9:02 Barney asked May 29, 2012 at 8:56 BarneyBarney 1,8485 gold badges31 silver badges51 bronze badges 1
  • 1 In what context is your JS running? – Jon Cram Commented May 29, 2012 at 9:31
Add a ment  | 

1 Answer 1

Reset to default 6

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);

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.

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();
发布评论

评论列表(0)

  1. 暂无评论