Highlighted

script to save as png

Explorer ,
Apr 30, 2020

Copy link to clipboard

Copied

Is there any script to save illustrator file to png in same directory. once saved AI file should be closed without saving. Also file naming of PNG should be as per AI file. please help me on this

resolution on png: 72

 

Topics

Scripting

Views

465

Likes

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

script to save as png

Explorer ,
Apr 30, 2020

Copy link to clipboard

Copied

Is there any script to save illustrator file to png in same directory. once saved AI file should be closed without saving. Also file naming of PNG should be as per AI file. please help me on this

resolution on png: 72

 

Topics

Scripting

Views

466

Likes

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
Adobe Community Professional ,
May 01, 2020

Copy link to clipboard

Copied

Hi, 
While exporting PNG via script, it is not possible to give resolution when exporting AI document either by ExportOptionPNG8 or ExportOptionsPNG24. For reference please see below screenshot

 

PNGOptions.png

 

But you can use option ImageCaptureOptions to export AI document into png while specifying the resolution. See below screenshot.

 

imageCapture.png

 

So, for your problem solution will be,

 

function saveAsPNG() {
    var pngFile = new File(app.activeDocument.path + "/" + app.activeDocument.name.split('.')[0] + '.png');
    var resolution = 72;
    var opts = new ImageCaptureOptions();
    opts.resolution = resolution;
    opts.antiAliasing = true;
    opts.transparency = true;
    try {
        app.activeDocument.imageCapture(pngFile, app.activeDocument.geometricBounds, opts);
        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    } catch (e) {

    }
}

saveAsPNG();

 

You can change value of resolution here as per your requirements.

Let us know if this helps you.

 

Thanks

Charu

Best regards

Likes

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
Reply
Loading...