2 Replies Latest reply on Nov 4, 2013 12:29 AM by Ketschak

    How to calculate the ExportPNG24 scalefactor

    Ketschak

      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
      10241025
      20482050
      40964100
      60006006
      80008008

      (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