exportOptionsPNG24.antiAliasing not working
Patrick-clone opened this issue · 1 comments
Patrick-clone commented
I want to export a PNG24 without anti aliasing via a custom written extension.
But the option exportOptionsPNG24.antiAliasing = false
does not in practice omit the anti aliasing when exporting a PNG24.
Example script:
function exportFileToPNG24(dest) {
if (app.documents.length > 0) {
var exportOptions = new ExportOptionsPNG24();
exportOptions.antiAliasing = false;
exportOptions.transparency = false;
var type = ExportType.PNG24;
var fileSpec = new File(dest);
app.activeDocument.exportFile(fileSpec, type, exportOptions);
}
}
Patrick-clone commented
I've found a solution to my problem, thanks to this post.
var dest = app.activeDocument.path;
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 = false;
rasterizeOptions.clippingMask = false;
rasterizeOptions.resolution = 72.0;
rasterizeOptions.transparency = false;
rasterizeOptions.convertSpotColors = true;
var fileExport = new File(dest);
var tmpLayer = app.activeDocument.layers.add();
var tmpGroup = tmpLayer.groupItems.add();
var pathItemsList = [];
for (var i = 0; i < app.activeDocument.pathItems.length; i++) {
if(!app.activeDocument.pathItems[i].hidden && !app.activeDocument.pathItems[i].clipping){
pathItemsList.push(app.activeDocument.pathItems[i]);
}
}
for (var i = pathItemsList.length - 1; i >= 0; i--) {
var pathItem = pathItemsList[i].duplicate(tmpGroup, ElementPlacement.PLACEATBEGINNING);
}
var tmpRast = app.activeDocument.rasterize(tmpGroup, app.activeDocument.artboardRect, rasterizeOptions);
app.activeDocument.exportFile( fileExport, type, exportOptions );
tmpRast.remove();
tmpLayer.remove();