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[2] - bounds[0];
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:
desiredWidth | resultingWidth |
1024 | 1025 |
2048 | 2050 |
4096 | 4100 |
6000 | 6006 |
8000 | 8008 |
(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[2] - bounds[0];
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