Posted by Vince Wadhwani on Jan 22, 2008

If you've updated your gems recently you may have noticed that the latest rmagick isn't working. I've run into this problem on Feisty, Gutsy, and Debian Sid. The culprit is a version of Imagemagick older than 6.3.0. The Rmagick gem used to work with Graphicmagick so I'm not entirely sure why it refuses to install, but I get an error that says:





Can't install RMagick 2.0.0. You must have ImageMagick 6.3.0 or later.

*** extconf.rb failed ***

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/rmagick-2.1.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/rmagick-2.1.0/ext/RMagick/gem_make.out

Bleh. In order to get around this, you'll have to compile Imagemagick from source. Here's how I did it (the somewhat painless way)

First thing you want to do is get rid of any installed older packages:

sudo apt-get remove imagemagick
sudo apt-get remove graphicsmagick

Next, grab the packages you'll need to install Imagemagick:

sudo apt-get install build-essential
sudo apt-get build-dep imagemagick

One more install to make sure you got everything:

sudo apt-get install gcc libjpeg62-dev libbz2-dev libtiff4-dev libwmf-dev libz-dev libpng12-dev libx11-dev libxt-dev libxext-dev libxml2-dev libfreetype6-dev liblcms1-dev libexif-dev perl libjasper-dev libltdl3-dev graphviz gs-gpl pkg-config 

Next grab the latest source for Imagemagick from the FTP server nearest you.

wget ftp://ftp.fifi.org/pub/ImageMagick/ImageMagick-6.3.8-0.tar.gz
tar xvzf ImageMagick-6.3.8-0.tar.gz

Let's build that sucker:

 cd ImageMagick-6.3.8/
./configure

You should make sure when you run ./configure that support is there for JPEG v1, JPEG-2000, PNG, and ZLIB at a minimum.. If so, then continue on.

make
sudo make install

With that done, let's try to install rmagick again:

sudo gem install rmagick

Hopefully you'll see output along these lines:

vince@redplume:~/ImageMagick-6.3.8$ sudo gem install rmagick
Building native extensions.  This could take a while...
Successfully installed rmagick-2.1.0
1 gem installed

Further troubleshooting: To confirm that Imagemagick is installed correctly after being compiled, run:

identify -list format

If instead of a listing of formats Imagemagick can handle, you get an error like "libMagick.so.10: cannot open shared object file" it means that one of your library paths did not get properly used during the installation. What you'll need to do is make sure /usr/local/lib is in your /etc/ld.so.conf/libc6.conf file. Assuming it is (if not, add it) run:

sudo ldconfig

After that, uninstall Imagemagick and the Rmagick gem and then reinstall them again.

And with that.. you're done!

Update: Or are you? For some reason I can't get rmagick to resize images on Gutsy even though it works on Debian. Next up installing ImageScience on Ubuntu.