【发布时间】:2013-10-23 06:11:31
【问题描述】:
我使用这个脚本通过 php-gd 库将 html 代码制作成图像:
<?php
//put your html code here
$html_code = '
<html>
<body>
Image Out Put sadadasdasdasdasdasd
</body>
</html>
';
$img = imagecreate("300", "600");
imagecolorallocate($img,0,0,0);
$c2 = imagecolorallocate($img,70,70,70);
imageline($img,0,0,300,600,$c2);
imageline($img,300,0,0,600,$c2);
$white = imagecolorallocate($img, 255, 255, 255);
imagettftext($img, 9, 0, 1, 1, $white, "arial.ttf", $html_code);
header('Content-type: image/jpeg');
imagejpeg($img);
?>
网站网址:
http://almogas.com/temp/phpimage.php?id=3
我得到了很多未知字符。如何解决此问题?
///////////////////////////////////////
编辑
现在删除空格后可以正常工作
但是有办法添加背景图片吗? 谢谢
【问题讨论】:
-
unknown char 是什么意思?您希望它如何工作?
-
Content-Type标头未正确发送。文档的 Content-Type 为text/html。 -
OP 正在尝试创建一个不正确的图像
Content-Type@Le_Morri -
这就是我要说的。他给定的代码是正确的。但是服务器没有这样做。
-
@putvande 这行得通。你检查输出了吗?