I have a problem with my FreeBSD 7.1 server. PHP's GD implementation no longer works on PNG images. Whenever the system tries to work with PNG images, I get these three error messages:
[Sat Jul 18 21:41:15 2009] [error] [client 90.34.34.34] PHP Warning: imagecreatefrompng() [function.imagecreatefrompng]: gd-png: fatal libpng error: [00][00][00][00]: unknown critical chunk in /usr/storage/www/private/mikkel.hoegh.org/modules/acquia/imageapi/imageapi_gd.module on line 44, referer: http://mikkel.hoegh.org/admin/build/imagecache/3 [Sat Jul 18 21:41:15 2009] [error] [client 90.34.34.34] PHP Warning: imagecreatefrompng() [function.imagecreatefrompng]: gd-png error: setjmp returns error condition in /usr/storage/www/private/mikkel.hoegh.org/modules/acquia/imageapi/imageapi_gd.module on line 44, referer: http://mikkel.hoegh.org/admin/build/imagecache/3 [Sat Jul 18 21:41:15 2009] [error] [client 90.34.34.34] PHP Warning: imagecreatefrompng() [function.imagecreatefrompng]: 'sites/mikkel.hoegh.org/files/imagecache_sample.png' is not a valid PNG file in /usr/storage/www/private/mikkel.hoegh.org/modules/acquia/imageapi/imageapi_gd.module on line 44, referer: http://mikkel.hoegh.org/admin/build/imagecache/3
I've been trying to solve this half a day now, and the best clue I've found is another guy having the same problem – no solution there, though.
The code in question is fairly simple, it just calls imagecreatefrompng($filename);
Package versions of all the packages I can think of that might be related:
- php5-5.2.10
- php5-gd-5.2.10
- png-1.2.37
- gd-2.0.35_1,1
Any clues?
Before updating always read
Sometimes you'll need to do recursive portupgrade i.e.
This command solve my problem:
portupgrade -fr png-1.2.40
If you are using portmaster, this will work:
This is very older bug in freebsd.
In
extensions.ini
the stringextension=gd.so
needs to be the first line.It could be problem with PNG image. Try very basic code with very small black and white PNG image. If that also generates same errors in log files then you could consider installing PHP from source so that modules like php_gd get updated to latest version.
You can also try setting
in case they give some better error message on screen. Remember to make
display_errors=Off
after you have finished debugging on a production server.I had a recent problem similar to this. After upgrading one of the packages on my 7.2 system, the gd-driven captcha on my phpBB2 installation stopped working. I re-built all of the php ports and it fixed itself.
I know that's a bit vauge, but sometimes things will break over months of incremental upgrades due to dependencies getting out of whack.
No answer but since I cannot leave any comment; I have a 7.2 system with exactly the same problem and exactly the same versions. Even tried downgrading libpng to no avail. Doing a binary upgrade from 7.1. to 7.2 was extremely painless and well worth it but don't think that will fix the problem :-)
I also installed pecl-imagick to see if I could use that instead but to my surprise I got similar errors. I tried lots of other software that depends on libpng but they could all load the images giving errors in php5-gd and pecl-imagick just fine. This made me exclude libpng, which at first I thought was the problem. My next guess is that something in the php API has changed, I will try to downgrade php and see if that helps.