Report this

What is the reason for this report?

Rails 4 PaperClip ImageMagick Content Type Error for Images

Posted on March 14, 2015

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

Paperclip::Errors::NotIdentifiedByImageMagickError

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.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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?

Thanks.

The List.

asb,

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”

Thanks

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 ?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.