• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Trouble using script to save PSD as PNG

Community Expert ,
Feb 20, 2024 Feb 20, 2024

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);

 

TOPICS
Actions and scripting

Views

136

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Feb 20, 2024 Feb 20, 2024

Copy link to clipboard

Copied

Do you have legacy save as set in your file handling preferences?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2024 Feb 20, 2024

Copy link to clipboard

Copied

I did not. I tried enabling it; same result. Which should it be set at? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2024 Feb 20, 2024

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2024 Feb 27, 2024

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.

brianp311_0-1709062140804.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 03, 2024 Mar 03, 2024

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines