Post a Comment
For some reason, Apple did not include GD in the default Leopard build. Here's how to compile just the GD extension and add it to PHP without recompiling the whole of PHP and breaking the unique folder layout &c. of the Apple install
mkdir -p libjpg
cd libjpg
curl -O http://www.ijg.org/files/jpegsrc.v6b.tar.gz
tar xzpf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
#32-bit
#./configure --enable-shared
#64-bit
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch x86_64 -g -Os -pipe" CXXFLAGS="-arch x86_64 -g -Os -pipe" LDFLAGS="-arch x86_64 -bind_at_load" ./configure --enable-shared
make
mkdir -p /usr/local/include
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
mkdir -p /usr/local/man/man1
sudo make install
cd ..
cd ..
mkdir -p gd
cd gd
curl -O http://www.opensource.apple.com/darwinsource/10.5/apache_mod_php-43/php-5.2 .4.tar.bz2
tar xjf php-5.2.4.tar.bz2
cd php-5.2.4/ext/gd
sudo phpize
#32-bit
#./configure --with-zlib-dir=/usr --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/X11R6 --with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6
#64-bit
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch x86_64 -g -Os -pipe" CXXFLAGS="-arch x86_64 -g -Os -pipe" LDFLAGS="-arch x86_64 -bind_at_load" ./configure --with-zlib-dir=/usr --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/X11R6 --with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6
make
sudo make install
#add "extension=gd.so" to php.ini
#and uncomment (";" before) 'extension_dir = "./"'
uncomment the 32-bit lines, and comment in the 64-bit lines if you're compiling on a Core !2 Duo / G4
Edited 2008-07-07 19:47 UTC
This is PHP/Apache. Both open source projects not run by Apple. These are also both not front-facing user options advertised on the box.
Having to run a ridiculously complex script to fix an issue is a staple of most open source projects. Blaming Apple is aiming in the wrong place.
...
Blaming Apple is aiming in the wrong place.
Apple is responsible for the configuration of the versions of PHP/Apache that Apple chose to include in Apple's OS (note the pattern).
Relevance? Correlation is not cause.
...which says to me that Apple's commitment to "user experience" is largely perfunctory, since it evidently doesn't extend to the more advanced / less "sexy" parts of the OS.
I've been using this for about a year or so now - it's incredibly useful when you need to do something like display dynamically-generated text using an exotic typeface.
A very useful script that I've come across, just in case anyone is looking for something similar:
- Multifunction Image Handler PHP Script
http://www.carmosaic.com/weather/scripts-image-handler.php
I haven't used more than a fraction of its functionality, but so far it's been quite handy for doing server-side creation of banner images from templates, and non-destructively watermarking photos.




