简体   繁体   English

没有对话框保存

[英]Saving without dialog window

I'm trying to write a script that will automate a bunch of stuff for Photoshop CS5. 我正在尝试编写一个脚本,该脚本将使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. 我一直在查看《 JavaScript工具指南》 ,但是没有找到一种方法。 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 编辑:特别是我想将文件保存为crytiff格式,但我只想知道如何保存具有所需扩展名的文件

The following saves the active document as PNG. 以下内容将活动文档另存为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); 

Try using Document.saveAs() . 尝试使用Document.saveAs() But, like El Cas said, you still have to pass in some kind of SaveOptions object. 但是,就像El Cas所说的那样,您仍然必须传递某种SaveOptions对象。 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 这是更完整的Photoshop CS5 Javascript参考

Open: Windows > Actions You will find Toggle Dialog On/Off check box before every action. 打开:Windows>操作您将在每个操作之前找到“切换对话框打开/关闭”复选框。 Turn it off. 把它关掉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM