Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails paperclip `is not recognized by the 'identify' command`

I am getting an error when trying to save a png to a model with a paperclip attachment.

My User model:

class User < ActieRecord::Base
  attr_accessible :icon
  has_attached_file :icon, :url => "/system/users/icon/:hash.:extension",
    :hash_secret => "superSecretHashSecret",
    :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

Example of trying to set an icon:

u = User.last
u.icon = open(Rails.root + "spec/fixtures/files/example.png")
u.save

Example model error:

:icon => ["/var/folders/43/810gn/T/example20121104-36855-1v7t136.png is not recognized by the 'identify' command."]

There are a number of people who have posted similar questions to this one, especially this one but none of those solutions work for me.

My command_path is set correctly:

O:~ $ which identify
/usr/local/bin/identify

In development.rb

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

This still might be the problem though. When trying to use `identify directly I get the following error:

O:~ $ identify workspace/app/spec/fixtures/files/example.png 
dyld: Library not loaded: /usr/lib/libltdl.7.dylib
  Referenced from: /usr/local/bin/identify
  Reason: image not found
Trace/BPT trap: 5

Any suggestions as to what is going on here?

I have tried reinstalling ImageMagick

brew unlink imagemagick
brew install imagemagick

Others have recommended adding Rmagick. It is definitely not a requirement for using Paperclip and it also did not help.

Another solution that has been suggested is removing the :style property. That isn't a solution though. I need to do the processing on the images.

I have Paperclip working on another model in my project that handles documents that are not images/don't do any processing. So I know that it is probably related to that.

Any other suggestions on how to address this problem?

like image 425
Andrew Hubbs Avatar asked Dec 08 '22 19:12

Andrew Hubbs


1 Answers

This is an ImageMagick installation problem.

First try

brew update
brew upgrade imagemagick

If that doesnt work, use magick-installer script to solve this: https://github.com/maddox/magick-installer

curl https://raw.github.com/maddox/magick-installer/master/magick-installer.sh | sh

Alternatively, use a fork of magick-installer with newer versions of dependent libraries:

curl https://raw.github.com/GTSouza/magick-installer/master/magick-installer.sh | sh
like image 85
glebm Avatar answered Dec 11 '22 10:12

glebm