Posted by Vince Wadhwani on Jan 22, 2008

I wrote up an article on compiling ImageMagick and installing Rmagick 2.1 but for some reason, even though the gem got installed, I couldn't resize images. After a half day banging my head against it, I finally gave up. Next up, ImageScience. It uses less memory anyway so if this serves your purpose, follow along.

You unfortunately won't be able to escape compiling. Credit where it's due: this post by Michael T on the Slicehost forum is where I got this working:

Step 1: sudo apt-get install build-essential
Step 2: wget http://ftp.cica.es/ubuntu/ubuntu/pool/universe/f/freeimage/freeimage_3.9.3.orig.tar.gz
Step 3: tar -xvf freeimage_3.9.3.orig.tar.gz
Step 4: cd freeimage-3.9.3.repacked/FreeImage
Step 5: make
Step 6: sudo make install

That'll get you FreeImage which is a requirement for ImageScience. Next up, ImageScience which installs easily via rubygems. Assuming you're using a version of Ruby Gems > 1.0 you don't need to identify all the requirements so just type:

sudo gem install image_science

All done! Wait, not quite. Chances are your app will work in development mode but once you're in production you're in for a world of hurt. But thanks to Stephen Sykes the answer to that problem is provided.

Edit your config/environment.rb file and add these lines in there somewhere:

if RAILS_ENV == "production" 
  ENV['INLINEDIR'] = RAILS_ROOT + "/tmp" 
end

If you fail to do that you may end up getting weird errors like ActionView::TemplateError: Expected mugshot.rb to define Mugshot