【发布时间】:2014-11-04 10:03:52
【问题描述】:
我用imagettftext()试试这个代码:
// Set the content-type
header('Content-Type: image/png');
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
但它不能正常工作,我安装了 GD 和 FreeType,如您所见:
谁能指出我正确的方向?
【问题讨论】:
-
您好,显示的错误是什么? (要查看它,请在删除内容类型标头后直接访问您的图像)。
标签: php gd freetype imagettftext