Rails 4中的Paperclip :: Errors :: NotIdentifiedByImageMagickError

时间:2014-09-29 08:18:15

标签: ruby-on-rails-4 paperclip

有以下型号:

class Picture < ActiveRecord::Base
  belongs_to :business

  has_attached_file    :image, styles: { medium: "640x260>" }
  validates_attachment :image, content_type: { :content_type => /\Aimage\/.*\Z/ }
end

此外,我已经安装了&#39; imagemagick&#39;使用brew(我使用Mac OS)。但是当我试图执行以下代码时

@picture = business.pictures.build(picture_params)
@picture.save

def picture_params
    params.require(:picture).permit(:image)
end

我收到以下错误:An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>

我正在尝试更新PNG文件:

= form_for [:admin, business, @picture] do |f|
    .row
        = f.file_field :image
        = f.submit 'Add'

如何解决问题?

2 个答案:

答案 0 :(得分:2)

我有同样的问题。我通过重新安装imagemagick来解决这个问题。

brew uninstall imagemagick jpeg libtiff
brew install imagemagick

如果没有链接,请在安装imagemagick之前链接freetype

brew link freetype

答案 1 :(得分:0)

使用identify验证imagemagick  你应该得到这样的东西: -

milind@ubuntu:~/workspace/latest$ identify
Version: ImageMagick 6.6.9-7 2014-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP   ....

并将其添加到development.rb( 了解您安装imagemagick的路径

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