malcoauri
malcoauri

Reputation: 12179

Paperclip::Errors::NotIdentifiedByImageMagickError in Rails 4

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?

Upvotes: 1

Views: 4644

Answers (2)

Santh Nish
Santh Nish

Reputation: 179

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

Upvotes: 2

Milind
Milind

Reputation: 5112

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"

Upvotes: 0

Related Questions