Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

7 Answers 7

up vote 1 down vote accepted

Before updating always read

/usr/ports/UPDATING

Sometimes you'll need to do recursive portupgrade i.e.

portupgrade -fr png-1.2.37
share|improve this answer
    
Was there anything in particular I should have noticed in UPDATING? I can't spot something related to this problem. I don't use portupgrade, but I'm running a sudo portmaster -ru graphics/png now to see if that'll fix it. –  mikl Jul 20 '09 at 20:39
    
Recursive rebuild did not fix the problem, sadly. I tried earlier by rebuilding all dependencies of php5-gd, but that had no effect either. –  mikl Jul 20 '09 at 20:56
    
maybe, as last resort, portmaster -fa will help? –  SaveTheRbtz Jul 20 '09 at 23:15
    
Thankfully, it has disappeared after I upgraded to FreeBSD 7.2. I think the decisive change was the complete rebuild of all packages. Thanks. –  mikl Jul 21 '09 at 22:14

This command solve my problem:

portupgrade -fr png-1.2.40

share|improve this answer

If you are using portmaster, this will work:

portmaster -dbrR png-1.2.40
share|improve this answer

This is very older bug in freebsd.

In extensions.ini the string extension=gd.so needs to be the first line.

share|improve this answer

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

error_reporting  =  E_ALL
display_errors = On

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.

share|improve this answer
    
Well, it is the same with all PNG images I've tried. And as far as I can see, the error message is exactly the same whether you output it to the log or to the screen. –  mikl Jul 20 '09 at 10:05
    
Based on your distribution you would have some package manager like yum or apt. Try updating apache, php, php_gd using that package manager. If that does not works then I guess recompiling PHP from source would be the best option. –  Saurabh Barjatiya Jul 20 '09 at 12:09
    
The versions I mentioned are the latest available – I have tried the upgrade strategy already… –  mikl Jul 20 '09 at 20:14

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.

share|improve this answer
    
Yeah, I already tried to rebuild php-gd with all of its dependencies. I think I might try something more… drastic. I have an upgrade to 7.2 I've been putting off for a while, so if I have to rebuild all my packages, that might be a good occation :) –  mikl Jul 20 '09 at 10:07

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.

share|improve this answer
1  
Okay, interesting – I've managed to get my image processing working by using imagemagic (the CLI util, not the pecl package). That could indicate that this might in fact be a PHP bug. shakes tiny fist at PHP –  mikl Jul 20 '09 at 20:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.