Question
Trouble using script to save PSD as PNG
Hi all,
I have the following code to resize and save a PSD as a PNG. It was working fine, and still works for some psds, but frequently I am getting a user Save a Copy prompt at the doc.saveAs line. Is there something I'm missing?
var path = File.openDialog().fsName;
app.rulerUnits = Units.PIXELS;
var pngOpts = new PNGSaveOptions;
try {
var doc = app.open(File(path));
} catch(e) {
alert("Could not open psd file " + path + ". " + e);
return;
}
if (doc.width > 1500) {
doc.resizeImage(1500, null);
}
var goodPath = path.replace(/psd|b$/gi,"png");
doc.saveAs(File(goodPath), pngOpts, true);
doc.close(SaveOptions.DONOTSAVECHANGES);
