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

ExtendScript Save PNG as JPEG without dialog

New Here ,
Aug 29, 2017 Aug 29, 2017

Copy link to clipboard

Copied

I've written a script in ExtendScript to process hundreds of image files. It works fine without any intervention if the original files are JPEGs. I however have started getting some PNG's. The script opens them fine and converts them to RGB. I set my JPEG save Options but when PS goes to save it brings up the Save As dialog box. Is there any way to avoid the dialog box?

My code:

var destFile = File(printFolder.fullName + "/" + doc.name);

var saveOptions = new JPEGSaveOptions( ); 

saveOptions.embedColorProfile = true;

saveOptions.quality = 12;

saveOptions.formatOptions = FormatOptions.STANDARDBASELINE; 

saveOptions.matte = MatteType.NONE; 

    

doc.saveAs (destFile, saveOptions, false );

TOPICS
Actions and scripting

Views

2.2K

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

correct answers 1 Correct answer

Community Expert , Aug 29, 2017 Aug 29, 2017

Have you tried adding this to your code:

app.displayDialogs = DialogModes.NO;

Votes

Translate

Translate
Adobe
Advocate ,
Aug 29, 2017 Aug 29, 2017

Copy link to clipboard

Copied

Try this out.

function saveJPG(saveFile, jpegQuality) {

    saveFile = (saveFile instanceof File) ? saveFile : new File(saveFile);

    jpegQuality = jpegQuality || 7;

    var jpgSaveOptions = new JPEGSaveOptions();

    jpgSaveOptions.embedColorProfile = true;

    jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;

    jpgSaveOptions.matte = MatteType.NONE;

    jpgSaveOptions.quality = jpegQuality;

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

}

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 ,
Aug 29, 2017 Aug 29, 2017

Copy link to clipboard

Copied

Have you tried adding this to your code:

app.displayDialogs = DialogModes.NO;

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
New Here ,
Aug 29, 2017 Aug 29, 2017

Copy link to clipboard

Copied

LATEST

Thanks Guys. Both options worked for me.

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