views:

765

answers:

1

Hi,

I'm using PaperClip plugin in my Rails application as follows:

  has_attached_file :photo, :styles => {:small => '64X64>', :medium => '250X250>'},
                                      :url  => "/assets/user_photos/:id/:style/:basename.:extension",
                                      :path => ":rails_root/public/assets/user_photos/:id/:style/:basename.:extension"
#  validates_attachment_presence :photo
  validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png','image/gif']
  validates_attachment_size :photo, :less_than => 1.megabytes

It works fine on development(Mac OSX + Mongrel). But when I put it in production (Linux Debian + Apache/Passenger) it only accepts .gif and I get the following error for .png and .jpg:

 Photo /tmp/stream20091028-20066-1t1a0oz-0 is not recognized by the 'identify' command.
 Photo /tmp/stream20091028-20066-1t1a0oz-0 is not recognized by the 'identify' command.

I tried adding the following line as some tutorials suggests but it didn't help!

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

Any ideas?

Thanks,

Tam

+3  A: 

On your production server, try running:

which identify

This should give you your path to ImageMagick's identify binary -- if it doesn't you don't have ImageMagick installed or it is not in your path.

If it returns something like "/usr/bin/identify", then you'll want to set the Paperclip options in your production.rb environment file to:

Paperclip.options[:command_path] = "/usr/bin"
bensie
Thanks Bensie. It actually gave: /usr/local/bin/identify
Tam
Then you likely don't have the necessary libs installed. ImageMagick can be a beast, particularly when installing from source. If possible, use the package manager of your OS to install it -- I've had much more success with that. What distro are you using?
bensie
I'm using Linux Debian on my server..I remember installing it long time ago and it worked in my previous Ruby 1.8.6/Rails 2.3.2 project but I wansn't using paper clip. Now I'm using Ruby 1.9 Rails 2.3.4. You think that makes a difference?
Tam