Compiling ImageMagick on Mac OS X using MacPorts

29 Aug 2007

If you work with graphic formats, you probably are or will use ImageMagick. And if you are using a pre-built binary, at some point you'll bump into a limitation and will need to compile it yourself.

Normally, one might try and do the ./configure; make; make install cycle using their instructions, but the dependencies are really complicated. You might get a minimally functional version to work, but will be missing fonts and functionality (believe me I tried).

On linux et al, mostly like some type package manager is available and you can use that. On Mac, you have two choices, fink and macports to automate the pain. Personally I've found macports a bit easier to use, and it worked out of box.

However ImageMagick is a complicated program and I found macports needed a few tweeks to make the ultimate binary. Here's what you need to do to install. Advanced users might have already done the first two steps.

1. Install XCode and X11 SDK

Head over to Apple's Developer Connection and download xcode. You might need to create a user id. Anyways, it's a monster download of around one gig.

Open up the file, and click on the XcodeTools.mpkg and go through the install. Then open up the Packages directory and click on X11SDK.pkg and install that.

2. Install MacPorts

This is an adbridged version of the official page UsingMacPortsQuickStart. Refer to this page if you run into trouble.

Go to MacPorts.org (note its plural, not MacPort). And find the latest download. Make sure you pick the right version for your OS. Download it and install.

Open up a Terminal and do sudo port -v selfupdate

3. Install special libraries

These are not technically necessary, but they make life better. The change to freetype allows for TrueType font-hinting to be turned. It's turned off since it's patented, but you can turn it on. It makes certain fonts look better

The librsvg is for rastering SVG images. ImageMagick uses it, but it also provides a direct SVG to PNG encoder ('man rsvg').

This takes a a while. Like it's time to get lunch. Somehow most of GTK is being downloaded and linked (although you won't be using much if any of it).

sudo port -v install freetype +bytecode
sudo port -v install librsvg

4. Install ImageMagick

Finally, let's install it with lots of special formats turned on. It doesn't take that long.

sudo port -v install ImageMagick +graphviz +gs +wmf +jbig +jpeg2 +lcms

5. Quick Check

If all goes well, which identify shoudl return /opt/local/bin/identify and identify -list type should list a lot of fonts.

Now you are ready to get some work done!

6. Man pages

Oh you want manpages? Sheesh. Add export MANPATH="/opt/local/man:$MANPATH" to your ~/.profile