I need to export a Illustrator icon in various different resolutions e.g. 16x16, 64x64, 256x256 etc.
I wrote a simple script for this purpose which is calculating the scalefactor out of the image width and the desired resolution.
The scale factor is calculated by this simple formular:
var bounds = item.visibleBounds; var width = bounds - bounds; var scaleFactor = 100.0 * desiredPixelWidth / width;
The resulting images are correct for small images from 16px to 512px but for larger images the resulting images are too big:
(the calculated value for width is 512.5)
I have to multiply the scaleFactor with a correctionFactor of ~0.999 to get correct results:
var bounds = item.visibleBounds; var width = bounds - bounds; var scaleFactor = 99.9 * desiredPixelWidth / width;
I am wondering if anyone knows why the correctionFactor has to be applied and what the correct value is.
Windows 7 64Bit / Adobe Premium CS5.5
what method are you using to scale the art?
Sorry for the late reply.
I don't scale the art at all. I only set the scaleFactor values for horizontal and vertical scale in the exportOptions:
var exportOptions = new ExportOptionsPNG24(); var type = ExportType.PNG24; exportOptions.horizontalScale = scaleFactor ; // default 100.0 exportOptions.verticalScale = scaleFactor ; // default 100.0 app.activeDocument.exportFile( fileSpec, type, exportOptions );