views:

805

answers:

1

When I try to upload a photo in Ruby on Rails using Paperclip on my local machine it works perfectly.

When I try to upload a photo in Ruby on Rails using Paperclip on our Linux (CentOS 5.2) server with Apache and Phusion Passenger, I get:

2 errors prohibited this user from being saved

There were problems with the following fields:

* Avatar /tmp/stream20091026-21120-1qdbnul-0 is

not recognized by the 'identify' command. * Avatar /tmp/stream20091026-21120-1qdbnul-0 is not recognized by the 'identify' command.

I tried adding Paperclip.options[:command_path] = "/usr/local/bin" to production.rb but it didn't make a difference.

In the log files I get the following errors:

Parameters: {"commit"=>"Upload", "action"=>"update", "_method"=>"put", "authenticity_token"=>"419410afc22737cd2f6b6096a95327db76a48ba9", "controller"=>"users", "user"=>{"avatar"=>#}} [paperclip] Saving attachments. [paperclip] An error was received while processing:

/tmp/stream20091026-20752-1g568yk-0 is not recognized by the 'identify' command.

+2  A: 

Identify is a command-line utility inside the ImageMagick package.

From its homepage:

The identify program describes the format and characteristics of one or more image files. It also reports if an image is incomplete or corrupt. The information returned includes the image number, the file name, the width and height of the image, whether the image is colormapped or not, the number of colors in the image, the number of bytes in the image, the format of the image (JPEG, PNM, etc.), and finally the number of seconds it took to read and process the image. Many more attributes are available with the verbose option.

First, copy the image on the server and run the identify command on it. You should receive something like:

identify ~/capture.jpg 
capture.jpg JPEG 1216x244 1216x244+0+0 8-bit DirectClass 97.7kb

If you receive an error, try upgrading the ImageMagick package on your server. You may find an updated binary release here: http://www.imagemagick.org/script/binary-releases.php

Vlad Zloteanu
After a lot of messing about I managed to work out that the libraries for .jpeg .png were not install on our linux production server, but they are installed on my imac. So I had to download those libraries and install them and then reinstall imagemagick (not helped by the fact imagemagick.org has been down all afternoon :( )
Chris