I always find it a challenge getting the perl GD.pm module working whenever I upgrade or do a fresh install of the operating system. The GD module is perl’s interface to the gd graphics library, which itself requires various libraries installed in order to work with jpegs, truetype fonts, etc. GD lets cgi scripts create custom graphics on the fly, like the Who Owns Vermont map Robin and I created for the Snelling Center a while back. GD can composite and caption photos, watermark them, resize them, convert GIFs to JPEGs or PNGs (and vice versa), draw charts and graphs, and so on. Fun and geeky stuff indeed.
Ever since the hard disk crashed last January, I’ve been unsuccessful getting GD to install despite several attempts using Fink, and even going so far as hunting down the sites hosting the individual parts and trying to install them. No go. (Note: The following assumes you’ve installed the Developer Tools, know what GD is for, and have already installed and configured CPAN.)
Yesterday I decided to try something completely different, and use Darwin Ports to install gd and all its parts. Darwin Ports itself was an easy download and install, so I was encouraged by this good start. I found gd as well as gd2 on the Available Ports, graphics category page; feeling brave, I decided to install the newer gd2. The page reported that gd2 requires the jpeg, libpng, XFree86, and freetype libraries, and I used ‘port’ command (installed by Darwin Ports) to install each of these libraries, like so:
> sudo port install jpeg
Installing software can take a while to compile and, making it a great time to surf the web, catch up on blogging, or whatever. Not a good time to use PhotoShop or other processor-intensive applications, tho, or you’ll be there forever because your Mac is crawling along at a snail’s pace.
Well, the jpeg and libpng libraries installed just fine, and altho XFree86 to a very long time to compile, at the very end it complained that another X package was already installed. I remembered installing Apple’s X11 when I installed Tiger, so I decided to leave that alone and continue with my install (hoping that wouldn’t cause a problem).
The freetype library also installed just fine (and pretty quickly, compared to the behemoth that’s XFree86). I held my breath and installed gd2, the graphics library that ties all the other libraries together. Thankfully, gd2 installed without complaint. And at this point I’m really liking this Darwin Ports thang!
With the last piece in place, it was time to install the GD.pm module, and of course CPAN is the best way to do that. It installed without a hitch, woohoo!
I ran a quick little test perl script that created a 100×100 gif, framed it with a red rectangle and drew some text in the center. And it worked! I was thrilled and pleased that Darwin Ports made installing gd so easy.