在php中使用imagettftext时出现HTTP错误500

时间:2013-06-29 12:38:04

标签: php

我正在尝试在php中生成并显示图像。但我得到HTTP错误500:遇到意外情况.....当我打破代码并重试几次,我发现错误是在我使用imagettftext的行。我的php版本是5.3.15,以下是我的代码。

$image = @imagecreate(120, 40) or die("Cannot Initialize new GD image stream");
$black = imagecolorallocate($image, 0, 0, 0);
putenv('GDFONTPATH='.realpath('.'));
$font = 'arial';
imagettftext($image, 20, 0, 10, 10, $black, $font , 'Print');

我在php文件所在的同一目录中有arial.ttf文件。我怀疑错误是因为php无法找到字体文件。 请在此处提出建议。

1 个答案:

答案 0 :(得分:0)

您的php安装中没有TTF支持。要启用TTF支持,必须使用以下选项之一配置php:--with-freetype-dir=DIR --with-t1lib[=DIR] --enable-gd-native-ttf

Read more about GD instalation

相关问题