views:

35

answers:

3

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

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

However, it says:

'http://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.)

+2  A: 

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

Ignacio Vazquez-Abrams
+4  A: 

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.

Dean Harding
+4  A: 

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

Scuzzy
Thanks a lot !!
Misha Moroshko