Strange GD error when working on PNG images from PHP on FreeBSD

6,693

Solution 1

Before updating always read

/usr/ports/UPDATING

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

portupgrade -fr png-1.2.37

Solution 2

This is very older bug in freebsd.

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

Solution 3

This command solve my problem:

portupgrade -fr png-1.2.40

Solution 4

If you are using portmaster, this will work:

portmaster -dbrR png-1.2.40
Share:
6,693

Related videos on Youtube

mikl
Author by

mikl

I am a web developer, open source enthusiast and a bit of a geek. I work for Liip AG, helping my customers do advanced web sites with Drupal and creating web applications with Node.js. You can also check out my blog.

Updated on September 17, 2022

Comments

  • mikl
    mikl over 1 year

    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?

  • mikl
    mikl almost 15 years
    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
    mikl almost 15 years
    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
    mikl almost 15 years
    The versions I mentioned are the latest available – I have tried the upgrade strategy already…
  • mikl
    mikl almost 15 years
    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
    mikl almost 15 years
    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
    mikl almost 15 years
    Recursive rebuild did not fix the problem, sadly. I tried earlier by rebuilding all dependencies of php5-gd, but that had no effect either.
  • SaveTheRbtz
    SaveTheRbtz almost 15 years
    maybe, as last resort, portmaster -fa will help?
  • mikl
    mikl almost 15 years
    Thankfully, it has disappeared after I upgraded to FreeBSD 7.2. I think the decisive change was the complete rebuild of all packages. Thanks.