RMagick
From DreamHost
RMagick at DreamHost
Ruby users can use RMagick to access the image processing functionality of ImageMagick.
The versions installed at DreamHost are well behind the current releases, and lack many of the newer features, and most critically, much needed bug fixes.
You can install your own versions to get around this limitation.
- Install your own version of ImageMagick, following the configuration instructions as given at Compiling ImageMagick
- This may take a few attempts, as it is very CPU intensive when running the tests, and this apparently causes DreamHost to periodically kill the build.
- If you're only planning on using ImageMagick for RMagick, you can save a little time and disk space by using
--without-perl --without-magick-plus-plus options when configuring ImageMagick to disable PerlMagick and Magick++
- Be sure to include the following configuration options
--with-gslib --with-gs-font-dir=/usr/share/fonts/type1/gsfonts/ - After installing ImageMagick,
cd ~and be sure to set the path for the binary and libraries. With these settings you'll be able to use RMagick under FastCGI without needing to work around the LD_LIBRARY_PATH environment variable:
- Be sure to include the following configuration options
$ export PATH=$HOME/local/bin:$PATH $ export LDFLAGS=-L/$HOME/local/lib $ export CPPFLAGS=-I/$HOME/local/include $ export LD_RUN_PATH=$HOME/local/lib
- Create your own gems repository
mkdir ~/gems - Set your gems environment
- Set environment variable
export GEM_PATH=$HOME/gems:/usr/local/lib/ruby/gems/1.8; export GEM_HOME=$HOME/gems - Configure ~/.gemrc (a YAML format file):
- Set environment variable
gemhome: /home/<user>/gems gempath: - /home/<user>/gems - /usr/local/lib/ruby/gems/1.8
- Make sure your .bash_profile is sourced (
source ~/.bash_profile) if your paths are in there. Double-check /local/bin is in your path withecho $PATH. - Download the gem file and install it from the downloaded copy. Dreamhost seems to kill the process when trying to install from remote.
$ cd ~/src $ wget 'http://rubyforge.org/frs/download.php/23510/rmagick-1.15.8.gem' $ gem install -l rmagick-1.15.8.gem -- --build-opts --prefix=$HOME/local
Now, you have a personal version of ImageMagick and of RMagick. To reference them, there are these additional steps:
- Update code to explicitly use the right version of the gem. Add this line to modules requiring RMagick support:
require_gem 'rmagick', '>= 1.15'
If your server has been upgraded to rubygems 0.9.0.8 or later (gem --version) use these lines instead, as require_gem is deprecated:
gem 'rmagick', '>= 1.15' require 'RMagick'
- For direct invocations of Ruby (including BackgrounDRB), be sure that the environment is set up (like GEM_PATH) before starting the Ruby process.
- For Rails invocations, set GEM_PATH in your environment.rb file, before running the Initializer (where the ENV['RAILS_ENV'] line is)
ENV['GEM_PATH'] = "/home/<user>/gems:/usr/local/lib/ruby/gems/1.8"
You can also try locking your gems for your application with rake rails:freeze:gems
Installed Versions Adequate (5/25/2007)
I (Edwin) find that the installed versions of ImageMagick and its (Ruby wrapper) RMagick to be adequate for my current needs, so I didn't perform my own installations of either.
To check the versions from the command interface:
convert -version (displays ImageMagick version) ls -d /usr/lib/ruby/gems/1.8/gems/rmagick* (displays all installed RMagick gems)
My Rails app -- which worked properly under InstantRails (Windows) -- did yield an "uninitialized constant Magick" error, because I omitted the "require 'RMagick'" line. Changing the relevant source to the following fixed the problem:
require 'rubygems' # ensure that the gem package is available gem 'rmagick', '>=1.12.0' # Add the rmagick gem to the module search path require 'RMagick' # Load RMagick.rb or RMagick.so

