Paperclip::Errors::NotIdentifiedByImageMagickError in Rails 4

别说谁变了你拦得住时间么 提交于 2019-12-08 04:26:10

问题


There is the following model:

class Picture < ActiveRecord::Base
  belongs_to :business

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

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

I got the following error: An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>

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?


回答1:


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

brew uninstall imagemagick jpeg libtiff
brew install imagemagick

Link freetype before installing imagemagick if it is not linked

brew link freetype



回答2:


verify imagemagick using identify you should get something like this:-

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   ....

and add this to development.rb(knowing your path where imagemagick is installed)

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


来源:https://stackoverflow.com/questions/26095396/papercliperrorsnotidentifiedbyimagemagickerror-in-rails-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!