SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    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:
    Code:
    [gd]
    ; 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:
    Code:
    ;extension=php_gd2.dll
    What am I missing?

    Many thanks,
    Mike

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Remove the semi-colon from
    Code:
    ;extension=php_gd2.dll
    save, and restart Apache. Hopefully, you'll now have the GD extension enabled.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks Anthony,

    having a little trouble restarting apache. I typed this in terminal command line:
    Code:
    sudo /usr/sbin/apachect1 restart
    And got this error message:
    Code:
    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

    EDIT:
    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?
    Last edited by mickyginger; Dec 12, 2010 at 08:46. Reason: Updated reply

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Try:-
    Code:
    sudo apachectl restart
    That's apachectl, not apachect1.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ha ha.

    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?

  6. #6
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    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?

    http://www.entropy.ch/software/macosx/php/

    Anthony.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  7. #7
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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.

    Cheers

  8. #8
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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:

    http://macoshelp.blogspot.com/2008/0...x-leopard.html

    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/libphp5.so" 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 http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz" 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

    @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!

  9. #9
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Ha, no worries.

    Glad you got it sorted, I'm just sorry I couldn't help further.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •