我几乎可以肯定这不起作用是有一个愚蠢的原因,但我就是想不通。我只是想用 imagettftext 将一些文本打印为图形,但我无法显示这些文字。这是在 GoDaddy 服务器上,所以我不能控制一切,但这里是 phpinfo() 的规范:
- PHP 版本 5.2.14
- --with-gd' '--with-freetype-dir=/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr/bin/libpng-config' '- -启用-gd-native-ttf'
- 启用 GD 支持
- GD 版本捆绑(2.0.34 兼容)
- 已启用 FreeType 支持
- FreeType 与 freetype 的链接
- FreeType 版本 2.2.1
这是我正在使用的代码。没有什么花哨或奇怪的。
$width = 270;
$height = 25;
$image = imageCreate($width, $height);
$white = imageColorAllocate($image, 255, 255, 255);
$black = imageColorAllocate($image, 0, 0, 0);
$font = 'verdana.ttf';
imagefttext($image, 16, 0, 0, 0, $black, $font, 'TESTING TEXT');
header("Content-type: image/gif");
imageGIF($image);
我尝试以不同的方式更改字体名称:
$font = './verdana.ttf';
$font = dirname(__FILE__).'/verdana.ttf';
我尝试使用 PNG 而不是 GIF,我尝试使用 imagefttext() 和 imagettftext(),我尝试显示错误,但它没有显示任何错误,只是一个空白屏幕。有任何想法吗?一定是这么愚蠢的事情……