1

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

Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746

3 Answers3

6

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

Scuzzy
  • 12,186
  • 1
  • 46
  • 46
4

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
  • 71,468
  • 13
  • 145
  • 180
2

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

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358