用imagettftext在图片上输入字符,无法在浏览器中生成图片
我imagettftext函数在图片上写入汉字字符串,可是却无法在浏览器中输出图片,使用imagepng($im,'x.png');可以将图片输出,但是如果直接输出到浏览器却不行,求高手调教啊。以下我的代码
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<?php
Header('Content-type: image/png');
putenv('GDFONTPATH=C:\WINDOWS\Fonts');
$button_text='Button按钮';
$button_text=$button_text.rand(30, 50);
$im=imagecreatetruecolor(400, 200);
$black=imagecolorallocate($im, 0, 0, 0);
$white=imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $black);
imagettftext($im,30,30, 0,150, $white,'MSYH.TTF', $button_text);
imagepng($im);//使用imagepng($im,'x.png');可以生成x.png,图片也有文字。
imagedestroy($im);
?>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号