它工作完美,直到我尝试使用文本字体。
这是我的代码.. 现在注释的 3er 行是可以正常工作的行...但是在此示例中,我试图用 imagettftext 替换此行.. 不走运。
我的错误是什么?
$newImage = imagecreatefromjpeg( "orsil_secure.jpg" );
$txtColor = imagecolorallocate($newImage, 0, 0, 0);
//imagestring($newImage, 5, 10, 27, $ranStr, $txtColor);
imagettftext($newImage, 5, 10, 27, $txtColor, $font_path, $ranStr);
header( "Content-type: image/jpeg" );
imagejpeg($newImage);
哦,是的,前几行是这里字体的路径:
// random number
$ranStr = md5(microtime());
$ranStr = substr($ranStr, 0, 6);
// Set Path to Font File
$font_path = 'captcha.TTF';