【问题标题】:Paperclip::Errors::NotIdentifiedByImageMagickError in Rails 4Rails 4 中的 Paperclip::Errors::NotIdentifiedByImageMagickError
【发布时间】:2014-09-29 08:18:15
【问题描述】:

有以下型号:

class Picture < ActiveRecord::Base
  belongs_to :business

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

我还使用 brew 安装了“imagemagick”(我使用 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: #&lt;Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError&gt;

我正在尝试更新 PNG 文件:

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

如何解决我的问题?

【问题讨论】:

    标签: ruby-on-rails-4 paperclip


    【解决方案1】:

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

    brew uninstall imagemagick jpeg libtiff
    brew install imagemagick
    

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

    brew link freetype
    

    【讨论】:

    • 对windows用户有什么建议吗??
    【解决方案2】:

    使用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"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多