Getting ImageMagick to work with Lion and ZSH

Don’t really know if this issue is specific to Lion and ZSH, but upon extracting the ImageMagick binary package (from here) to /usr/local/ on Lion, I couldn’t get it to work as per the instructions on the ImageMagick site. I would just download it or use the Rails gem (rmagick), but since I installed Lion, make doesn’t work any longer and since it’s nearing the end of the month I can’t stand off the bandwidth for the xcode4 download.So, this:

➜  ~  identify

Gave the following output:

dyld: Library not loaded: /ImageMagick-6.7.1/lib/libMagickCore.4.dylib
  Referenced from: /usr/local/ImageMagick-6.7.1/bin/identify
  Reason: image not found

In case you were wondering, the “image not found” it refers to is the library mentioned on the first line, not the image your trying to manipulate with ImageMagick. I actually part of the solution to the problem on StackOverflow here. It that ZSH, and subsequently Rails, has the wrong path to the libMagickCore.4.dylib library – the path in the error does look a bit funky.

So, solution was to add the following to my .zshrc (if case you don’t know, it’s in your home directory)

export DYLD_LIBRARY_PATH=/usr/local/ImageMagick-6.7.1/lib

PS. Don’t forget to also add the MAGICK_HOME path, as well as add the the bin path to your PATH. Your paths in .zshrc should look something like the following:

# Customize to your needs...
export MAGICK_HOME=/usr/local/ImageMagick-6.7.1/
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin/:/usr/local/ImageMagick-6.7.1/bin
export DYLD_LIBRARY_PATH=/usr/local/ImageMagick-6.7.1/lib

Hope this prevents some hair loss for somebody ;)

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>