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.

  • 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
    Commented Sep 2, 2013 at 18:43
  • I found that argument for rasterize should be not selection but one object or group.
    – amrok
    Commented Sep 3, 2013 at 9:01

1 Answer 1


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();
    t.name = '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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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