tags:

views:

388

answers:

1

Hey guys,

in one of my PHP projects, imagecreatefrompng complains, that the image "is not a valid PNG file".

Warning: imagecreatefrompng() [function.imagecreatefrompng]:
'/.../...png' is not a valid PNG file in /.../...php on line ...

I'm pretty sure, the file is valid, because I can open it in any program. So I was wondering what else could cause this warning.

Does anybody know the details behind imagecreatefrompng or has had a similar problem before?

Thanks for your help,

Timo

+2  A: 

Is it a PNG image? Run file against it, or try the fileinfo functions.

Ignacio Vazquez-Abrams
Thanks for the link to the fileinfo functions. I let PHP check the mime type and surprisingly enough the image was a jpg file - renaming it to .jpg solved the problem.I guess every program I opened the file with automatically detected the mime type correctly...
Timo