# Installing RMagick on the Macintosh

This should be considered the fourth post in the “Digital photos and me” series. I thought this might interest a broader audience than the previous posts in the series, so I gave it title that would stand out more.

Well, it’s been a few weeks since the first three installments in this series. The demands of work are the primary reason for the delay, but the new iMac has also played a role. The prerequisites for installing RMagick—our topic for the day—are many, and when you have an older computer with lots of installed software, the prerequisites are easy to forget because they may have been installed months earlier for another purpose. But with a virgin computer, I could figure out exactly what was needed—no more, no less. So I held off on the post until I had a chance to do the installation on the new iMac. That chance came today, so I’m writing it up before I forget what I did.

First, I suppose I should mention the purpose of installing RMagick and what it has to do with digital photos. RMagick is the Ruby interface for accessing the ImageMagick library, a large set of routines for manipulating, combining, and converting digital image files. I wanted a cleaner, command-line version of my old photopage program, and I wanted to write it in Ruby rather than Python. I had used PIL, the Python Imaging Library to write photopage, a library that wasn’t going to be available for Ruby. RMagick seems to be the standard image manipulation library for Ruby, so I went with it.

Next, I’ll warn you that this article, which was linked on Daring Fireball and is ranked fairly high in a Google search on “RMagick os x,” is likely to give you trouble. As near as I can tell, it doesn’t install the fonts that ImageMagick and RMagick need, so you’ll end up with a library that can’t put text in your images. If I’m wrong about this, please educate me.

On the other hand, this article, which is also has a high Google ranking, is very good. I kept it up on one of my Safari tabs to refer to as I did my installation.

# Step 1—Install the XCode development tools

These will be on your Tiger installation disk. You can also download them if you’ve signed up (for free) with Apple’s Developer Connection. The downloaded version is the best bet, as it will be the most recent. This is a normal package-type installation: you double-click on the package and it leads you through a few simple steps.

# Step 2—Install DarwinPorts

The DarwinPorts project is in flux right now as it moves from one host to another. It’s also changing its name to MacPorts, but the change isn’t reflected everywhere. Don’t let the apparent schizophrenia deter you; DarwinPorts is, in my opinion, the best way to install Unix/Linux software on your Mac. If you’re not familiar with it, here is a nutshell description: it’s an automated way of downloading, configuring, compiling, and installing software with a single command.

I’ve used DarwinPorts’ main competitor, Fink, in the past, but not any more. DarwinPorts packages are usually more up-to-date and give me fewer installation problems. Yes, compiling everything does take more time (Fink can install pre-compiled packages), but I end up with a package tuned for my system. With the change to Intel processors, this is a bigger deal than it used to be.

So anyway, download the latest DarwinPorts from this repository. At present, version 1.3.2 is the latest, and because it doesn’t come in .dmg form you’ll have to download the source code, unzip it, then manually configure and compile it using the directions in the README file. This isn’t such a big deal. Open a Terminal window, go into the DarwinPorts directory and issue the commands

./configure
make
sudo make install


in that order. This will install DarwinPorts in /opt/local. All of the software you will now install with DarwinPorts will also go in that directory, so you need to make sure it’s in your path. I added the line

# Step 4—Install RubyGems

OK, now it’s time to install another package manager, this one specific to Ruby called RubyGems. You can download it from its rubyforge site (rubyforge, as its name implies, is like a sourceforge for ruby), unpack it somewhere convenient, and issue the command

sudo ruby setup.rb


from within the rubygems directory. This will install a new program, called gem, which works a lot like port. As with port, the first thing you should have gem update itself:

sudo gem update --system


sudo gem install rmagick