问题
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