PHP imagick annotate setFont超过了最大执行时间

时间:2010-12-07 21:37:15

标签: php macos imagemagick imagick

我试着用php imagick为图像写一些文字。 它在我的服务器上运行正常,但我在macbook上运行它时遇到问题。

代码:

/* 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;

当我在我的macbook上运行它时,处理器停留在100%,并且该过程在30秒内被终止,并显示以下消息:在第13行的.....超过30秒的最大执行时间,是$ draw-> setFont();

的那个

感谢您的回复......

1 个答案:

答案 0 :(得分:0)

猜猜:您的系统上没有Arial,或者提供字体的完整路径setFont()

$draw->setFont('/path/to/ARIALB.ttf');