Posted on

Install ImageMagick from source on OS X Tiger (and Leopard)

Update Feb. 10, 2008: Ive tested and verified this also works on OS X Leopard. An additional command was needed to make the JPEG library install without errors, noted below. Ive also updated the commands outlined below for the latest versions of the software.

 

If you’re like me and use mini_magick or (or RMagick) Ruby gems on OS X for building Rails apps, installing ImageMagick can be a pain. There is a universal binary package which works alright, but I prefer to build apps from source when possible. Also, I run a few web sites on my G5 Power Mac and I want ImageMagick to be compiled specifically for the PowerPC platform, which will get me a bit of an advantage in speed and reliability. I ran into a few roadblocks while getting it all compiled and installed, so I thought I’d share how I did it.

 

First off, I should mention that I only added in JPEG and PNG support for ImageMagick, so if you need more formats supported, this article doesn’t cover it. You’ll also need the OS X Developer Tools installed on your system. Finally, I did this on the latest version of OS X (Tiger 10.4.9) for PowerPC and Intel Macs. Both tested working. Update: Also tested on OS X Leopard on Intel.

 

Here is a list of packages you’ll need to download. Get all of these and place them in one directory.

  • JPEG
  • LibPNG
  • ImageMagick

Once you’re done downloading, open the Terminal app and go to the folder you downloaded the files to. For example if you downloaded them do your Desktop, type the following in the command line and hit enter:

  cd Desktop

Step One: Compile and Install JPEG Libraries

Installing the JPEG libraries is actually the trickiest part of the install. By default on OS X building and installing the JPEG libraries won’t install any libraries at all, only some binaries that allow you to manipulate JPEG files.

 

Update: I also discovered while installing the JPEG library on Leopard that it needs the /usr/local/man/man1 directory to install without errors. I added the command below to create it.

So here’s the magic to force it to install JPEG libraries that ImageMagick will use while compiling:

  tar zxvf jpegsrc.v6b.tar.gz
  cd jpeg-6b
  cp /usr/share/libtool/config.sub .
  cp /usr/share/libtool/config.guess .
  sudo mkdir -p /usr/local/man/man1
  ./configure --enable-shared --enable-static
  make
  sudo make install
  sudo ranlib /usr/local/lib/libjpeg.a
  cd ../

Done! You shouldn’t have gotten any errors. If you did, then make sure you definitely have the OS X Developer Tools installed.

Step Two: Compile and Install LibPNG

This is pretty straightforward, and doesn’t require any weird tricks to get it to work.

  tar zxf libpng-1.2.24.tar.gz
  cd libpng-1.2.24
  ./configure
  make
  sudo make install
  cd ../

Step Three: Compile and Install ImageMagick

This is pretty simple too. We don’t have to pass any special options to ImageMagick either. It should automatically pick up that we have JPEG and PNG libraries installed and compile in support automatically.

  tar zxf ImageMagick.tar.gz
  cd ImageMagick-6.3.8/
  ./configure

After ./configure is done, you should check to make sure the following lines are present in the output that indicated JPEG and PNG support are in there:

  JPEG v1           --with-jpeg=yes               yes
  PNG               --with-png=yes                yes

If those are both set to yes, then you’re golden. Now finish him!

  make
  sudo make install

Leave a Reply

Your email address will not be published. Required fields are marked *