Search code examples
phppngthumbnailsimagecreatefrompng

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:

'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.)


Solution

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