开发者

How to create PNG thumbnail if "imagecreatefrompng()" fails?

I start to create a PNG thumbnail by using this function:

$image = imagecreatefrompng("http://imagenic.net/images/pfujz9j5juav1qrex00.png");

However, it says:

'h开发者_开发百科ttp://imagenic.net/images/pfujz9j5juav1qrex00.png' is not a valid PNG file

It works OK with other PNG images, so I guess something is wrong with this specific picture.

What can I do in this situation ?

Is there another way to create the thumbnail ?

(BTW, I found this picture in the web.)


Using getimagesize() returns a mime value of image/jpeg, you can call this function to determine which imagecreatefrom... function to call next.


According to Firefox, that image is actually a JPEG image. Someone's just given it the wrong extension. You can use the finfo_file function to check the actual type of the file by sniffing it's header.


Try one of the other imagecreatefrom*() functions. Or use the fileinfo functions and stop guessing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜