Php 使具有文本功能的图像不工作
我正在尝试创建一些带有文本的图像。以下是我创建的函数:Php 使具有文本功能的图像不工作,php,image,text,Php,Image,Text,我正在尝试创建一些带有文本的图像。以下是我创建的函数: function makeTitleImage($text){ $im = imagecreatetruecolor(160,160); $background_color = imagecolorallocate($im,154,205,50); $text_color = imagecolorallocate($im,255,255,255); imagefill($im,0,0,$background_color);
function makeTitleImage($text){
$im = imagecreatetruecolor(160,160);
$background_color = imagecolorallocate($im,154,205,50);
$text_color = imagecolorallocate($im,255,255,255);
imagefill($im,0,0,$background_color);
imagettftext($im,10,0,0,$text_color,"./ASansBlack.ttf",$text);
header('Content-Type: image/png');
imagepng($im,($text.'.jpg'));
imagedestroy($im);
}
这将创建一个160x160px图像,背景色为,但没有适当命名的文本(因此我知道$text
被正确地传入)。.ttf
文件的路径是准确的。不确定还会发生什么?可能有点傻
谢谢 您的
imagettftext
函数缺少一个参数,即文本的y坐标。试试像这样的东西
imagettftext($im,10,0,0,10,$text_color,"./ASansBlack.ttf",$text);
啊,看,我就知道这会很愚蠢。非常感谢你!