Many projects require the use of Image Magick to automatically resize and generate thumbnails for their applications. Recently, I have set up my server to house Rails applications and the next steps would be to install Image Magick and also a mail server to handle emails.

Install Image Magick

yum install gcc*

Note that yum install imagemagick will not work on Centos properly.

cd /tmp

Head to ftp://ftp.fifi.org/pub/ImageMagick/ and find out the latest release of the .tar.gz file.

wget ftp://ftp.fifi.org/pub/ImageMagick/ImageMagick-x-x-x-x.tar.gz

This will download the files into the tmp folder.

tar xzf ImageMagick-x.x.x-x.tar.gz
cd ImageMagick-x.x-x.tar.gz
.configure

Untar the file and configure the installation.

make 
make install

After this I realized that I actually need the RMagick gem. However in my local machine I did not install this and Paperclip works just fine. I am just gonna omit the RMagick gem and see how things goes.

It actually works so long as there is a link to the Imagemagick folder in the environment file. In /config/environments/production.rb insert this code :

  Paperclip.options[:command_path] = "/usr/local/bin/"

The path may differ depending on the installation, to find out the full path, you can run this command.

 which convert

Now in your /home/demoapp/public/system folder, you have to ensure that it has proper permission so that Paperclip can write to it. You may need to change ownership to the git user if it is not working.

After that restart apache and Paperclip uploads will work.