Home > PHP > Add GD Support for PHP

Add GD Support for PHP

February 15, 2006 Posted by KP

To enable image (JPEG/PNG) manipulation for PHP, install gd extension from ports:

# cd /usr/ports/graphics/php4-gd
# make install clean
# apachectl graceful

If a PHP script needs gd module but can’t find it, it will display the following error:
Fatal error: Call to undefined function: imagecreatefromjpeg()

P.S. A simple problem could be troublesome for newbies if they can’t find the right web pages. When searching the solution to the above error, a FreeBSD user may be led to a Linux page which states that PHP must be recompiled with gd support. But this is not applicable for FreeBSD system. Hopefully, after I blog this problem, Google will lead them to this post, so that they can enable gd support for PHP within minutes without touching the main PHP installation.

Bookmark and Share


Related Posts:

Filed Under: PHP

8 Comments to “Add GD Support for PHP”

  1. Anonymous Says:

    This didnt work for me

  2. Anonymous Says:

    You need to rebuild php with the correct switch

  3. FreeBSD Newbie Says:

    That’s strange…I specially tested it on a second server, the only thing I did is installing gd extension.

  4. Marc Says:

    Yah… this did not work for me either… just tried to install it from ports… installs fine, just doesn’t show up in phpinfo() …

  5. Anonymous Says:

    Helpful, as I was trying to solve a similar problem: install MySQL support for PHP, not GD.

  6. bsd-n00b Says:

    Hey, this worked perfectly for me. The only difference is I used pkg_add -r php4-gd.

    I’m running 6.0 RELEASE, and I needed it for a drupal install. Worked perfectly as documented above. Make sure you don’t forget to HUP apache, though! Drupal didn’t pick up gd until I did the “apachectl graceful” step. After that - sweet as.

    Cheer
    Bill G.

  7. Ben Says:

    Worked very well for me with only a few minor differences. I’m using PHP5, so I replaced your first line with this:
    # cd /usr/ports/graphics/php4-gd

    As far as re-compilation of php goes, i’m uncertain of it’s prior status. I was never getting the error that you show in the example, but i was installing it to enable captcha in Gallery2, so Gallery tested for the GD support before I’d even hit that error.

    Thank you.

  8. Josh Says:

    Thanks! That was exactly what I needed!

Leave a Comment









*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word




Categories

Archives

Links

  • Dedicated Servers
  • Meta