: Looking for an illustrator script to export without anti-aliasing I'm looking for a workaround to export raster without anti-aliasing. ExportType.PNG 8/24 with exportOptions.antiAliasing = false export
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.
More posts by @Eichhorn212
1 Comments
Sorted by latest first Latest Oldest Best
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') {
array.push(item.pageItems[i]);
}
}
}
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 = [];
process(z);
for (var i = array.length-1; i>=0; i--) {
tmpSel = array[i].duplicate();
tmpSel.moveToBeginning(tmpGroup);
};
tmpRast = d.rasterize(tmpGroup, d.artboardRect, rasterizeOptions);
app.activeDocument.exportFile( fileExport, type, exportOptions );
tmpRast.remove();
t.remove();
}
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.