[英]PHP issue with Gd in WAMP (imagejpeg doesn't work)
I'm using WAMP 2.2 on windows XP 32bit. 我在Windows XP 32bit上使用WAMP 2.2。 I tried to make simple php script, which draws image, but something went wrong and I came back to simple examples from web. 我试图制作简单的PHP脚本,它绘制图像,但出了点问题,我回到了网上的简单例子。 But even then images don't show (only "blank-image" icon). 但即使这样,图像也不会显示(只有“空白图像”图标)。
Here's example code (from php webpage): 这是示例代码(来自php网页):
<?php
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
header('Content-Type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>
Best thing is when I add second parameter in "imagejpeg" method, which is output file name it actually works: 最好的是当我在“imagejpeg”方法中添加第二个参数时,它实际上是输出文件名:
imagejpeg($im, "output.jpg");
Things I tried/checked: 我试过/检查过的事情:
Right now I'm out of ideas. 现在我没有想法。
Please help, Regards ;) 请帮忙,问候;)
Finally found solution by my own. 终于找到了我自己的解决方案。 Php script was saved in "UTF8 encoding", but it has to be "UTF without BOM" (it can be done with notepad++). Php脚本以“UTF8编码”保存,但必须是“没有BOM的UTF”(可以用记事本++完成)。
So it was issue neither with script or wamp configuration, but just wrong encoding. 所以它既不是脚本或wamp配置的问题,而是错误的编码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.