Skip to main content
Inspiring
July 24, 2019
Answered

Setting the resolution output in an export PNG script

  • July 24, 2019
  • 2 replies
  • 4643 views

I have created a simple script that loops through each artboard in an open illustrator document and exports it as a separate PNG file. All is working well except that I want to set the resolution to 150 dpi and not 72 dpi for production reasons. This is an option that you can set when exporting manually to PNG but I don't seem to be able to set it in the PNG options in the code, although the script runs without errors it ignores the resolution setting. Could someone let me know what I'm doing wrong, many thanks. Code as follows:

var doc = app.activeDocument;;//Gets the active document

var fileName = doc.name.slice(0, 9);//Gets the G Number

var numArtboards = doc.artboards.length;//returns the number of artboards in the document

var filePath = (app.activeDocument.fullName.parent.fsName).toString().replace(/\\/g, '/');

$.writeln("fleName= ",fleName)

$.writeln("numArtboards= ",numArtboards)

$.writeln("filePath= ",filePath);

var options = new ExportOptionsPNG24();

  

for (var i = 0; i < numArtboards; i++ ) {

    doc.artboards.setActiveArtboardIndex( i );

   

    option.resolution = 150;

    options.artBoardClipping = true; 

    options.matte = false;

    options.horizontalScale = 100;

    options.verticalScale = 100; 

    options.transparency = true; 

    var artboardName = doc.artboards.name;

    $.writeln("artboardName= ", artboardName);

        var destFile = new File(filePath + "/" + fileName + " " +  artboardName + ".png");

        $.writeln("destFile= ",destFile);

          doc.exportFile(destFile,ExportType.PNG24,options);

    }

This topic has been closed for replies.
Correct answer CarlosCanto

use document.imageCapture() function, it has a resolution property

 

here's a sample

https://community.adobe.com/t5/illustrator-discussions/export-symbols-as-png-script-with-resolution/m-p/8652400#M215910

2 replies

Inspiring
July 24, 2019

Thanks for that, I added the resolution line into the post at the end,  so missed the s off, its there in my original code. I'll take a look at the document object and sem if that helps. Thanks for you time

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
July 24, 2019

use document.imageCapture() function, it has a resolution property

 

here's a sample

https://community.adobe.com/t5/illustrator-discussions/export-symbols-as-png-script-with-resolution/m-p/8652400#M215910

rcraighead
Legend
July 24, 2019

"document.imageCapture()" greatly improved my workflow.

Lumenn
Inspiring
July 24, 2019

First thing i've noticed:

option.resolution = 150;

options.artBoardClipping = true;

There is a missing "s".

But yeah, there is no resolution property in ExportOptionsPNG24 at least there is no information about it in documentation.

I've found that the Document object has resolution property, maybe that's some way.

Document — Illustrator Scripting Guide 0.0.1 documentation