Install FreeImage & ImageScience on Ubuntu Gutsy
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
I am really having a nasty time getting any of these graphics libraries to work well. I’ve been using RMagick1/ImageMagick for a while, but the Mongrel memory usage is killing me.
I tried switching to ImageScience, but it apparently cannot do some of the resizing I need.
Now I want to try RMagick2, since it adds some memory management tools, but it sounds like RMagick2 wasn’t too friendly to you.
Ugh. This has been a pretty big waste of time. My mongrel threads are still chewing up memory (and swapping like crazy) and I’m no closer to a solution than when I started :(
Thanks for the write-ups! This one especially was a big help.
Micah