PHP绘制png图像 显示红叉

redoffice 2009-05-31 04:56:19
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>6-2</title>
</head>
<body>
<?php
header("Content-type:image/png");
$im = @imagecreate(200,100)or die("11");
@imagecolorallocate($im,240,150,225);
$t_color1 = imagecolorallocate($im,0,0,0);
$t_color2 = imagecolorallocate($im,100,100,100);
imagestring($im,5,8,10,"I like PHP!",$t_color1);
imagestringup($im,5,8,90,"Hello!",$t_color2);
imageellipse($im,65,65,55,55,$t_color1);
imagefilledrectangle($im,110,95,160,30,$t_color2);
imagepng($im);
imagedestroy($im);
?>
</body>
</html>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>6-1</title>
</head>
<body>
<img src="6-2.php">
</body>
</html>



说明:png图片显示不出来,是一个红叉,GD信息如下:
gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.1.9
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled


求高人指点,本人初学者,谢谢
...全文
108 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2009-06-01
  • 打赏
  • 举报
回复
6-2.php
<?php
header("Content-type:image/png");
$im = @imagecreate(200,100)or die("11");
@imagecolorallocate($im,240,150,225);
$t_color1 = imagecolorallocate($im,0,0,0);
$t_color2 = imagecolorallocate($im,100,100,100);
imagestring($im,5,8,10,"I like PHP!",$t_color1);
imagestringup($im,5,8,90,"Hello!",$t_color2);
imageellipse($im,65,65,55,55,$t_color1);
imagefilledrectangle($im,110,95,160,30,$t_color2);
imagepng($im);
imagedestroy($im);
?>
neohope 2009-05-31
  • 打赏
  • 举报
回复
不是你的代码错了,是你应用php的路径错了
以/作为web的顶目录,试试,比如/web/php/test.php
redoffice 2009-05-31
  • 打赏
  • 举报
回复
已经去的很干净了
诶。。。
  • 打赏
  • 举报
回复
输出图像之前,不能有任何输出,把空格都去了
redoffice 2009-05-31
  • 打赏
  • 举报
回复
忘了说了,去掉html后一样显示红叉。。。苦恼中
phpboy 2009-05-31
  • 打赏
  • 举报
回复


<?php
header("Content-type:image/png");
$im = @imagecreate(200,100)or die("11");
@imagecolorallocate($im,240,150,225);
$t_color1 = imagecolorallocate($im,0,0,0);
$t_color2 = imagecolorallocate($im,100,100,100);
imagestring($im,5,8,10,"I like PHP!",$t_color1);
imagestringup($im,5,8,90,"Hello!",$t_color2);
imageellipse($im,65,65,55,55,$t_color1);
imagefilledrectangle($im,110,95,160,30,$t_color2);
imagepng($im);
imagedestroy($im);
?>



把 html 部分去了,试试

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧