PHP image_jpeg 不'如果文件是 UTF-8,则有效;如果文件是 ANSI,则有效
我使用此类来裁剪、调整图像大小: http:// www.phpclasses.org/package/4268-PHP-Resize-crop-rotate-flip-flop-and-grey-images.html
它使用GD。问题是我这样做:
$img = new ImageTransform;
$img->view('resize', 'foo.jpg', '500x400', true); // true argument is $cache = true
现在我可以指出
<img src="that_script.php" alt="" />
and it will show that image resized. But it doesn't if all my files are UTF-8! Only if they ALL are ANSI encoded. The image simply won't display if some or all files are encoded UTF-8. If i remove headers.. and just let it print all the things... I can see all funny characters... so it's printing something! But it just won't print the actual image with headers...在 PHP 文档中我发现有人这样写: http://no.php.net/manual/en/function。 imagejpeg.php#96796
对使用 utf-8 脚本的用户发出警告: 在像我一样疯狂一整天并挖掘配置文件等之前。
使用 image_jpeg 的直接浏览器输出仅在我以 ANSI 而不是 utf-8 保存脚本后才起作用
所以这一定是 PHP 出了问题吗?我使用 PHP 版本:5.3.2
PHPClasses 没有人抱怨有什么问题,所以我不认为这是这个类的问题。但是 PHP 的一些东西。 问题是如何让它与 UTF-8 一起工作?
感谢您的帮助!
I use this class to crop, resize my image:
http://www.phpclasses.org/package/4268-PHP-Resize-crop-rotate-flip-flop-and-grey-images.html
It uses GD. The problem is that I for example do this:
$img = new ImageTransform;
$img->view('resize', 'foo.jpg', '500x400', true); // true argument is $cache = true
Now I can just point
<img src="that_script.php" alt="" />
and it will show that image resized.
But it doesn't if all my files are UTF-8! Only if they ALL are ANSI encoded. The image simply won't display if some or all files are encoded UTF-8.
If i remove headers.. and just let it print all the things... I can see all funny characters... so it's printing something!
But it just won't print the actual image with headers...
In the PHP documentation I found someone write this:
http://no.php.net/manual/en/function.imagejpeg.php#96796
WARNING for those who use utf-8 scripts:
Before going crazy like me for a whole day and digging around configuration files etc.DIRECT BROWSER OUTPUT using image_jpeg worked only after i have saved my script in ANSI instead of utf-8
So it must be something wrong with PHP? I use PHP version: 5.3.2
Nobody at PHPClasses complains about something wrong, so I don't think it's the class. But something with PHP.
The question is how can I make it work with UTF-8?
Thanks for help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否可以将文件另存为 UTF8 BOM ?这可能会搞砸图像输出,因为 BOM 字符总是先输出。尝试将其另存为 UTF8 No-BOM,它应该与 ANSI 文件相同。
Are you possibly saving the files as UTF8 BOM? That would likely screw up image output, since the BOM character is always output first. Try saving it as UTF8 No-BOM, that should be identical to ANSI files.