Using Javascript to save files in Photoshop without a prompt?

时光怂恿深爱的人放手 提交于 2019-12-24 12:47:07

问题


I am using a simple script to edit an existing image.

No matter what I do, a save prompt always comes up. I want this to be 100% automated.

save() gives me a saveAs prompt to save it as a copy. close(SaveOptions.SAVECHANGES) just gives me a generic "Do you wish to save before closing?" box that I still need to select Yes on. saveAs() gives me the same as save(), except I can toddle the "As copy" option off... but that still doesn't help.


回答1:


Try this instead:

// where fPath is your file path
// jpgSaveOptions.quality controls the quality of the jpeg

// save out the image as jpeg
var jpgFile = new File(fPath);
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.formatOptions = FormatOptions.OPTIMIZEDBASELINE;
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 12;

activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE);

There is a known bug with compatibility issues of Photoshop, but I dodn't think this is it.

And just for the record Photoshop can be scripted in either Applescript, JavaScript or Visual Basic



来源:https://stackoverflow.com/questions/33032288/using-javascript-to-save-files-in-photoshop-without-a-prompt

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