问题描述
我想使用一些GD图像功能,所以我运行了几个
短脚本以查看它是否有效,例如:
<?php
/ *创建一个红色方块* /
$ image = imagecreate(200,200);
$ colorRed = imagecolorallocate($ image,255,0,0);
imagefill($ image,0,0,$ colorRed);
/ /发送图片
header(" Content-type:image / jpeg");
imagejpeg($ image);
?>
但他们生成的所有内容都是垃圾字符,没有图片,以
开头
??? ?JFIF ????? t> CREATOR:gd-jpeg v1.0(使用IJG JPEG v62),默认
质量?? C ?????????? ...(等等)
然后我运行了一个脚本来查看安装了什么版本
(var_dump(gd_info());)并生成它:[" GD Version"] => string(24)
" bundled(2.0兼容)"
那么为什么它不会产生jpeg?我做错了什么或
这是图书馆本身吗? (这是使用主机帐户
godaddy.com。它不是我安装的PHP或GD库。)
谢谢,
Eric
I would like use some of the GD image functions, so I ran a couple of
short scripts to see if it worked, such as:
<?php
/* Create a red square */
$image = imagecreate(200, 200);
$colorRed = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $colorRed);
//send image
header("Content-type: image/jpeg");
imagejpeg($image);
?>
but all they generates are garbage characters and no image, starting
with:
???àJFIF?t>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default
quality ??C ... (etc.)
I then ran a script to see what version was installed
(var_dump(gd_info());)and it generated: ["GD Version"]=> string(24)
"bundled (2.0 compatible)"
So why doesn''t it generate a jpeg? Am I doing something incorrectly or
is it the library itself? (This is using a hosting account at
godaddy.com. It is not PHP or a GD library that I installed).
Thanks,
Eric
推荐答案
这篇关于使用GD库函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!