对了,有一个很有深度的图片问题 php gd库,输出字符串可以,但是似乎无法输出汉字,该怎么办??————————个性签名————————————图片中转站develop.web-103.com 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $text = '学习进度概况'; $red = imagecolorallocate($image, 235, 20, 20); //imagestring($image, 5, 0, 0, $text, $red); $font = 'new.ttc'; imagettftext($image, 20, 0, 100, 40, $red, $font, $text); 什么怎么回事?gd库本来就可以给图片加汉字的。new.ttc 或者其他的ttf字体文件载入即可,然后imagettftext可以输出汉字。 字体文件你要包含到路径里边加到系统环境变量或者copy字体文件到你的网站目录。这是我做的一个简单的示例,上面的就是文字 <?phpheader("Content-type: image/jpeg");$image = imagecreate(450, 300) or die("Cannot Initialize new GD image stream");$text = '天天向上!!!!'; $bg = imagecolorallocate($image, 225, 240, 206); $red = imagecolorallocate($image, 204, 0, 0); //imagestring($image, 5, 0, 0, $text, $red); $font = './arial.ttf'; imagettftext($image, 20, 0, 100, 40, $red, $font, $text); imagejpeg($image);imagedestroy($image);?> 还是不行,,求原因 Warning: imagettftext() [function.imagettftext]: Invalid font filename in上面是你的错误,你可以将header注释后执行 arial.ttf不支持中文吧?换个=支持中文的。什么华文了,什么宋体了。。 header("Content-type: image/jpeg");$image = imagecreate(450, 300) or die("Cannot Initialize new GD image stream");$text = 'aaa天天向上!!!!'; $bg = imagecolorallocate($image, 225, 240, 206); $red = imagecolorallocate($image, 204, 0, 0); $font = 'msyhbd.ttf'; imagettftext($image, 20, 0, 100, 40, $red, $font, iconv('gbk', 'utf-8', $text));imagejpeg($image);imagedestroy($image); 哈哈。。那个其实是你的错误,因为你没有把字体文件加入系统环境变量(或copy到网站根目录) <meta charset="gb2312" />这样就可以了 汗!!!!! 诚心请教一个php读取文件的问题,谢谢了.都帮帮我啊. php结合mysql树状菜单问题 今天发现的一个上传文件的问题 PHP实现超大文件上传(1G) 如何判断该用户已经登录 关于SmartTemplate的缓存 (唠叨 请进) 为什么我每次关闭MYSQL都发生错误? 数据库里提出的数据,在表格内不能自动换行 怎么去除数组指定下标元素 问下这种传值链接是怎么搞的 把本地的程序,上传到服务器,怎么会产生bom代码??
$red = imagecolorallocate($image, 235, 20, 20);
//imagestring($image, 5, 0, 0, $text, $red);
$font = 'new.ttc';
imagettftext($image, 20, 0, 100, 40, $red, $font, $text);
什么怎么回事?
gd库本来就可以给图片加汉字的。
new.ttc 或者其他的ttf字体文件载入即可,然后imagettftext可以输出汉字。
字体文件你要包含到路径里边加到系统环境变量或者copy字体文件到你的网站目录。
这是我做的一个简单的示例,上面的就是文字
header("Content-type: image/jpeg");
$image = imagecreate(450, 300)
or die("Cannot Initialize new GD image stream");
$text = '天天向上!!!!';
$bg = imagecolorallocate($image, 225, 240, 206);
$red = imagecolorallocate($image, 204, 0, 0);
//imagestring($image, 5, 0, 0, $text, $red);
$font = './arial.ttf';
imagettftext($image, 20, 0, 100, 40, $red, $font, $text);
imagejpeg($image);
imagedestroy($image);
?> 还是不行,,求原因
不支持中文吧?换个=支持中文的。什么华文了,什么宋体了。。
$image = imagecreate(450, 300) or die("Cannot Initialize new GD image stream");
$text = 'aaa天天向上!!!!'; $bg = imagecolorallocate($image, 225, 240, 206);
$red = imagecolorallocate($image, 204, 0, 0);
$font = 'msyhbd.ttf';
imagettftext($image, 20, 0, 100, 40, $red, $font, iconv('gbk', 'utf-8', $text));
imagejpeg($image);
imagedestroy($image);
那个其实是你的错误,因为你没有把字体文件加入系统环境变量(或copy到网站根目录)