Rails 4 中的 Paperclip::Errors::NotIdentifiedByImageMagickError [英] Paperclip::Errors::NotIdentifiedByImageMagickError in Rails 4

查看:52
本文介绍了Rails 4 中的 Paperclip::Errors::NotIdentifiedByImageMagickError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有以下模型:

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(我使用 Mac OS)安装了imagemagick".但是当我尝试执行以下代码时

Also I've installed 'imagemagick' using brew (I use Mac OS). But when I was trying to execute the following code

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

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

我收到以下错误:处理时收到错误:#<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>

我正在尝试更新 PNG 文件:

I was trying to update PNG file:

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

我该如何解决我的问题?

How can I fix my problem?

推荐答案

我遇到了同样的问题.我通过重新安装 imagemagick 解决了这个问题.

I had the same issue. I resolved this by reinstalling the imagemagick.

brew uninstall imagemagick jpeg libtiff
brew install imagemagick

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

Link freetype before installing imagemagick if it is not linked

brew link freetype

这篇关于Rails 4 中的 Paperclip::Errors::NotIdentifiedByImageMagickError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆