title: Slow font rendering in ImageMagick
body: <p>I'm using the following ImageMagick script (with Imagick for PHP) to generate an image of a font. This script takes about 0.1 seconds to generate an image of about 30 characters at size 48. The target speed is about 0.01 seconds. I'm afraid switching to the GD library may be the only way to achieve this (I read <a href="http://www.rubblewebs.co.uk/imagemagick/compair.php" rel="nofollow">here</a> that text generation is much faster in GD). However, without features like gravity and trim, it's much more cumbersome to generate this type of image using GD. Does anyone see an obvious bottleneck in this code, or is it time to switch libraries?</p>
  
  <pre><code>$image = new Imagick();
  $draw = new ImagickDraw();
  $background = new ImagickPixel('none');
  $draw-&gt;setFont($font);
  $draw-&gt;setFontSize($size);
  $draw-&gt;setFillColor(new ImagickPixel('#'.$color));
  $draw-&gt;setGravity(Imagick::GRAVITY_CENTER);
  $draw-&gt;annotation(0, 0, $text);
  $image-&gt;newImage(5*mb_strlen($text, 'UTF-8')*$size, 5*$size, $background);
  $image-&gt;setImageFormat('png');
  $image-&gt;drawImage($draw);
  $image-&gt;trimImage(0);
  $image-&gt;writeImage($path_server['dirname'].'/'.$path_server['basename']);
  </code></pre>