GD support with PHP 5

Hey there,

I’m using PHP 5.2.14 on Mac OS X Leopard, and I’m trying to use the function imagecreatefrompng(); but I keep getting a fatal error: call to undefined function.

I’ve just done a search of the php.ini file so that I can enable gd (I’m looking for something like --with-gd), but there’s nothing there.

All I can find is this:

; Tell the jpeg decode to libjpeg warnings and try to create
; a gd image. The warning will then be displayed as notices
; disabled by default
;gd.jpeg_ignore_warning = 0

and this:


What am I missing?

Many thanks,

Remove the semi-colon from


save, and restart Apache. Hopefully, you’ll now have the GD extension enabled.

Thanks Anthony,

having a little trouble restarting apache. I typed this in terminal command line:

sudo /usr/sbin/apachect1 restart

And got this error message:

sudo: /usr/sbin/apachect1: command not found

Not hugely au fait with Terminal commands so not sure what I’m looking for. Bit scared about messing around with sudo tho… :s

So I tried just turning off web sharing in system preferences, then back on again. I’m still getting the error message ‘Call to undefined function imagecreatetruecolor()’… Is there something I’ve missed?


sudo apachectl restart

That’s apachectl, not apachect1. :wink:

Ha ha. :rolleyes:

OK so I’ve done that, still not joy. Double checked the php.ini file, and that semi-colon is definitely not there.

Any other ideas?

Actually, as you’re on OS X, the .dll obviously will not exist. Sorry, I’m an idiot.

Does the PHP package that ships with OS X even have GD? If not, you either have to install GD and recompile PHP with the module enabled or find an OS X package with GD already enabled.

I’m not a Mac user, so I’m a little out of my depth, does this look like it could be of some use?


Well from what I gather, yes it does ship with GD. In fact from what I gather from forums its best to activate the shipped library rather than install another copy of it.

I had a look on the link you posted, and the only mention of GD is here:

The module includes many popular PHP extensions, among them:

the MySQL and PostgreSQL databases
the cURL library for various communications protocols
the GD image creation library (with PNG, JPEG, PostScript Type 1 and TrueType font options).
the expat XML parser and WDDX support
XSLT transformations
LDAP access
the IMAP client library
mcrypt encryption functions
GNU gettext

Hmm, well, I’ll keep digging. I’m sure something will come up.


Ok, so after a little digging on t’interweb I found this solution that works for anyone who is using the native installation of PHP 5 on Leopard (OS 10.5). I don’t understand exactly what’s going on here, but I thought I’d post it just so that this thread would be resolved.

So I got this from this blog post:

But NOT from the main post, from a comment made by Sheldon about a third of the way down the page.

[If you] are trying to get this done on Leopard’s base PHP5 installation, here’s what you do.

-> Open Terminal App
-> Write “cd /private/etc” and press return
-> Use your favorite text editor to open httpd.conf
-> Find this “LoadModule php5_module libexec/apache2/” and add a “#” (no quotes) at the front of the line to comment out Leopard’s default PHP5 library
-> Write “cd /usr/local” and press return
-> Write “sudo curl -O” and press return
-> Write “sudo tar -xzf php5-*-beta.tar.gz” and press return
-> Write “sudo ln -sf /usr/local/php5/entropy-php.conf /etc/apache2/other/+entropy-php.conf” and press return
-> (Optional) Write “rm php5-5.2.5-6-beta.tar.gz” and press return to delete the downloaded archive
-> Write “sudo apachectl restart” and press return

Worked for me :slight_smile:

@Anthony – I just realised that the link you sent me was for the entropy site that is used in this solution. Completely missed that. I thought it was the specs of the Mac OS build! :rolleyes:

Ha, no worries. :slight_smile:

Glad you got it sorted, I’m just sorry I couldn’t help further.