我无法使用imagecreatefrompng()打开此PNG文件 [英] I can't open this PNG file with imagecreatefrompng()
问题描述
这是一个PNG文件: http://imgur.com/NUl4v.png (是的,没关系那是一只带有标志的有趣的企鹅...)
Here is a PNG file: http://imgur.com/NUl4v.png (Yes, never mind that it's a funny penguin with a sign...)
运行以下代码时:
imagecreatefrompng('http://imgur.com/NUl4v.png');
我得到一个错误:
PHP警告:imagecreatefrompng() [function.imagecreatefrompng] :无法读取/home/test/...中的图像数据
PHP Warning: imagecreatefrompng() [function.imagecreatefrompng]: Cannot read image data in /home/test/...
PNG文件似乎很好-我可以用不同的编辑器打开它,并且Unix file
命令报告它是:
The PNG file seems to be fine - I can open it with different editors, and the Unix file
command reports that it is:
PNG image, 640 x 360, 8-bit/color RGB, non-interlaced
PHP版本: 5.2.13
GD版本:已捆绑(兼容2.0.34)
PHP version: 5.2.13
GD version: bundled (2.0.34 compatible)
推荐答案
我不知道为什么,但是以下方法可行:
I have no idea why, but the following works:
imagecreatefromstring(file_get_contents('http://imgur.com/NUl4v.png'));
这篇关于我无法使用imagecreatefrompng()打开此PNG文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!