Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
Do you have legacy save as set in your file handling preferences?
Copy link to clipboard
Copied
I did not. I tried enabling it; same result. Which should it be set at?
Copy link to clipboard
Copied
OK, so that wasn't the answer for the script.
It needs to be set at whatever your preference is! :]
https://helpx.adobe.com/photoshop/using/saving-images.html#save-as
When you get the prompt, what colour mode and bit depth is the file?
Copy link to clipboard
Copied
Sorry for the lag. Color profile shows ICC. Sorry, where do I find the bit depth? It shows CMYK/8 in the file name.
Copy link to clipboard
Copied
The CMYK/8 indicates that this is 8 BPC (also found under the Image > Mode menu).
PNG doesn't support CMYK colour mode, you need to convert a copy to RGB mode, usually the sRGB profile as the lowest common denominator.