PHP imagick annotate setFont exceeds max execution time
Im tryin to write some text to an image using php imagick. It run开发者_开发技巧s okay on my server, but i have a problem running it on my macbook.
the code:
/* Text to write */
$text = "Hello World!";
/* Create Imagick objects */
$image = new Imagick();
$draw = new ImagickDraw();
$color = new ImagickPixel('#000000');
$background = new ImagickPixel('none'); // Transparent
/* Font properties */
$draw->setFont('Arial');
$draw->setFontSize(50);
$draw->setFillColor($color);
$draw->setStrokeAntialias(true);
$draw->setTextAntialias(true);
/* Get font metrics */
$metrics = $image->queryFontMetrics($draw, $text);
/* Create text */
$draw->annotation(0, $metrics['ascender'], $text);
/* Create image */
$image->newImage($metrics['textWidth'], $metrics['textHeight'], $background);
$image->setImageFormat('png');
$image->drawImage($draw);
/* Save image */
header("Content-type: image/png");
echo $image;
When i run this on my macbook, the processor gets stuck at at 100%, and the process is killed in 30 seconds with the message: Maximum execution time of 30 seconds exceeded in.....on line 13, which is the one with $draw->setFont();
Thank you for your responses...
Guess: Arial is not available on your system or provide a complete path for the font to setFont()
$draw->setFont('/path/to/ARIALB.ttf');
精彩评论