Saving without dialog window

*爱你&永不变心* 提交于 2019-12-02 20:04:11

问题


I'm trying to write a script that will automate a bunch of stuff for Photoshop CS5. Part of this involves saving a bunch of files. Is there a way to save a file in a way that doesn't open up a dialog window? I've been looking over the JavaScript Tools Guide, but I didn't see a way to do this. This suggested I used an action to deal with it but I'd really prefer not to do that.

EDIT: specifically I want to save the files as crytiff format but I'd just like to know how to save a file with whatever extension I want


回答1:


The following saves the active document as PNG. You can change the type to save it as.

// reference open doc
var doc = app.activeDocument;

// set save options
var opts = new ExportOptionsSaveForWeb();

opts.PNG8 = false;
opts.transparency = true;
opts.interlaced = false;
opts.quality = 100;
opts.includeProfile = false;
opts.format = SaveDocumentType.PNG; // Document Type

// save png file in same folder as open doc
activeDocument.exportDocument(doc.path, ExportType.SAVEFORWEB, opts); 



回答2:


Try using Document.saveAs(). But, like El Cas said, you still have to pass in some kind of SaveOptions object. You don't necessarily have to specify all the options if you don't want. You can just use the generic object like this:

app.activeDocument.saveAs(new File(doc.path + "/myDocument"), TiffSaveOptions);
// or BMPSaveOptions or GIFSaveOptions or JPEGSaveOptions...

Here's a much more complete Photoshop CS5 Javascript Reference




回答3:


Open: Windows > Actions You will find Toggle Dialog On/Off check box before every action. Turn it off.



来源:https://stackoverflow.com/questions/14389175/saving-without-dialog-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!