Rails 4 PaperClip ImageMagick Content Type Error for Images

March 14, 2015 4.1k views
Ruby on Rails Nginx

I'm using ImageMagick and Paperclip for uploading images to my Rails app. It is working on my development machine, a Mac, but not here. When Paperclip tries saving different sizes of the images, ImageMagick give the error


I'm using Paperclip 4.2.1. In my Rails model I have:

has_attached_file :photo_image, :styles => { :medium => "330x250#", :small => "150x120#", :thumb => "120x100#" }, 
                                :url => "/system/dadverts/:attachment/:id/:style/:filename",
                                :path => ":rails_root/public/system/dadverts/:attachment/:id/:style/:filename",
                                :default_url => "300250ad.png"

validates_attachment_content_type :photo_image, :content_type => /\Aimage/

In my production environment settings I have:

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

I've run sudo apt-get update a couple of times but this has not resolved the issue.

Any suggestions on what could be wrong would be appreciated.

5 Answers

Judging from the paperclip documentation, Paperclip.options[:command_path] should be set to the path that the convert binary and other ImageMagick utilities are installed at. How did you install ImageMagick?

If you installed it using apt-get on Ubuntu it is likely in /usr/bin/ not /usr/local/bin/ What is the output of which convert ?


I did install from source code, I found the instructions from somewhere but can't find the URL. It does upload GIF files but nothing else.

"which convert?" shows "/usr/local/bin/convert"


  • ImageMagick can be compiled with options to support different image formats. Check the output of convert -list format and make sure that you've compiled it with support for the image formats you need.

    The default Ubuntu package seem to have reasonable defaults. I'd suggest installing it using sudo apt-get install imagemagick and changing the path to /usr/bin/

asb, I checked the list and found that JPEG and PNG were missing from the list. I'll try your suggestion and let you know how it goes. Do you think I should delete the current installation and start over? If so, what recommendations would you have for making sure I get it all and not leave anything behind that would cause any conflicts?


The List.

I'm finally back trying to fix my ImageMagick problem. I ran a search and found I have several references to ImageMagick with different version numbers. I installed version 6.9.0 from source, which only works with GIFs. How do I clean this up to install as suggested by ash?

find / -name ImageMagick

Can I just delete "/usr/local/lib/ImageMagick-6.9.0"?

Have another answer? Share your knowledge.