Saturday, October 27, 2012

RMagic - image processing for RoR

I have a few projects that required basic image manipulation. Easy stuff like cropping and resizing images that users upload in the application.

Image Magic provides a nice solution for this both on Windows and Linux (the two environments i use) although they also provide libraries for MAC.

To install on windows first download and install the windows installer for Image Magic.
Note that you will need the installer to include the C libraries as well.

Then proceed to install the RMagick gem by this command (source):

gem install rmagick -- '--with-opt-dir="[path to ImageMagick]"'
And don't miss any character. just replace the [path to ImageMagic] with the location the installer put the image magic installation.

The installation for Ubuntu  is slightly easier:

apt-get update
sudo apt-get install imagemagick libmagickcore-dev
sudo apt-get install libmagickwand-dev
sudo gem install rmagick


Once you have the gem installed, add the following line to the gem file:
gem "rmagick", "~> 2.13.1"
And run the following command:
bundle

In the files you want to use this gem include:
require 'rubygems'
require 'RMagick'


You may find the instructions for the image manipulation facilities useful as well.

No comments:

Post a Comment

Please do not post spam on this blog, Spam sites will be reported to google.
thank you kindly.