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.
Related Posts:
Filed Under: PHP
February 21st, 2006 at 6:55 am
This didnt work for me
March 9th, 2006 at 9:35 pm
You need to rebuild php with the correct switch
March 10th, 2006 at 5:22 am
That’s strange…I specially tested it on a second server, the only thing I did is installing gd extension.
March 20th, 2006 at 2:42 am
Yah… this did not work for me either… just tried to install it from ports… installs fine, just doesn’t show up in phpinfo() …
April 10th, 2006 at 10:17 am
Helpful, as I was trying to solve a similar problem: install MySQL support for PHP, not GD.
April 29th, 2006 at 2:59 am
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.
March 1st, 2008 at 10:55 pm
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.
February 28th, 2010 at 3:34 pm
Thanks! That was exactly what I needed!