Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a workaround to export raster without anti-aliasing.

ExportType.PNG 8/24 with exportOptions.antiAliasing = false export with anti-aliasing.

The only way I know is to export manually to BMP, but this isn't an option. I need strict bitmap colors in my files because of color-coding.

I already tried app.activeDocument.rasterize, but the script just stops after reaching this line.

share|improve this question
I just tried adobe-illustrator-rasterize-script and it didn't work. I'm using Adobe Illustrator CS5.1 (15.1.0) for PC and now I'm very confused. – amrok Sep 2 '13 at 18:43
I found that argument for rasterize should be not selection but one object or group. – amrok Sep 3 '13 at 9:01
up vote 1 down vote accepted

Here is full version of two functions for exporting color-coded zones without anti-aliasing.

The first of them adds recursively all visible objects (in all nested layers and groups) for further rasterization.

function process(item){
    if (item.layers) {
        for (var i = 0; i < item.layers.length; i++) {
            if(item.layers[i].visible) process(item.layers[i]);
    if (item.groupItems) {
        for (var i = 0; i < item.groupItems.length; i++) {
            if(! item.groupItems[i].hidden) process(item.groupItems[i]);
    for (var i = 0; i < item.pageItems.length; i++) {
        if (item.pageItems[i].typename != 'GroupItem') {

This is main export function. It processes array z (in my case I've prepared it first from specified layer: var z = d.layers.getByName('/Zones')) and export rasterized PNG file without anti-aliasing.

function saveZones(name){
    var exportPath  = '/Source/Zones/';
    var exportOptions = new ExportOptionsPNG24();
    var type = ExportType.PNG24;
    exportOptions.artBoardClipping = true;
    exportOptions.antiAliasing = false;
    exportOptions.transparency = false;
    exportOptions.saveAsHTML = false;

    var rasterizeOptions = new RasterizeOptions();
    rasterizeOptions.antiAliasingMethod = AntiAliasingMethod.None;
    rasterizeOptions.backgroundBlack = true;
    rasterizeOptions.clippingMask = false;
    rasterizeOptions.resolution = 72.0;
    rasterizeOptions.transparency = false;
    rasterizeOptions.convertSpotColors = true;

    var fileExport = new File(filePath+exportPath+name);
    var t = d.layers.add(); = 'tmp '+name;
    var tmpGroup = t.groupItems.add();
    array = [];
    for (var i = array.length-1; i>=0; i--) {
        tmpSel = array[i].duplicate();
    tmpRast = d.rasterize(tmpGroup, d.artboardRect, rasterizeOptions);
    app.activeDocument.exportFile( fileExport, type, exportOptions );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.