PaperClip Error NotIdentifiedByImageMagickError wh

2020-06-30 05:10发布

I have been banging my head against this for several days. Recently, my image uploader has stopped working properly. I have investigated several possibilities, but have none of the suggested solutions have worked in my case.

The error message is:

#<Paperclip::Errors::NotIdentifiedByImageMagickError:Paperclip::Errors::NotIdentifiedByImageMagickError> 

Here are the details:

  • Mac OS X 10.8.3
  • ImageMagick 6.8.4-4 2013-03-29
  • libtool => /usr/bin/libtool
  • Rails 3.2.13
  • Ruby 1.9.3p194

development.rb contains appropriate path (and I have verified that it is correct using which identify)

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

Gemfile.lock (relevant portion)

paperclip (3.4.1)
  activemodel (>= 3.0.0)
  activerecord (>= 3.0.0)
  activesupport (>= 3.0.0)
  cocaine (~> 0.5.0)

MODEL (I am updating a classroom object, but the picture resides in the location model. (Classroom has_one :location, :as => :locatable)

Model location.rb

class Location < ActiveRecord::Base
  ## Paperclip method for uploading location images

  has_attached_file :picture, :styles => {:show => "1200x500#", :medium => "300x300#", :thumb => "100x100>"}, :convert_options => {:show => "-gravity center"}  
  has_attached_file :building_sign, :styles => { :show => ["1200x500#", :jpg], :medium => ["300x300#", :jpg], :thumb => ["100x100#", :jpg] }, :convert_options => {:show => "-gravity center"}
  belongs_to :locatable, :polymorphic => true
  belongs_to :location_type  
  validates :name,  :presence => true

  validates :latitude, :presence => true,
                       :length => {:within => 9..18},
                       :numericality => true
  validates :longitude, :presence => true,
                        :length => {:within => 9..18},
                        :numericality => true
end

Controller classrooms_controller.rb

def update
  @classroom = Classroom.find_by_facility_code_heprod(params[:id].upcase)

  respond_to do |format|
    if @classroom.update_attributes(params[:classroom])
      format.html { redirect_to(@classroom, :notice => 'Classroom was successfully updated.') }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @classroom.errors, :status => :unprocessable_entity }
    end
  end
end

What I've tried.

  • I've made sure that the image name is simple (USB2230.jpg), no colons.
  • I've updated the version of ImageMagick to the most recent.
  • I've also re-downloaded and reinstalled the CommandLine Tools for 10.8.3 (someone suggested that the issue might be related to an outdated libtool).
  • I've rebooted the computer.
  • I've tried variations on gem versions including

    # variation 1
    gem 'paperclip', '~> 2.8.0'
    gem "cocaine", "=0.3.2"
    
    # variation 2
    gem "paperclip", "~> 3.4.0"
    gem "cocaine", "= 0.4"
    
    # variation 3 (which is what is reflected in the included Gemfile.lock info above).
    gem "paperclip", "~> 3.4.0"
    

If I remove the scaling,

:styles => {:show => "1200x500#", :medium => "300x300#", :thumb => "100x100>"},
:convert_options => {:show => "-gravity center"}

the upload works, but I kind of need the scaling ;-)

Can anyone see something I am missing?

11条回答
我命由我不由天
2楼-- · 2020-06-30 05:40

Please update the version of paperclip gem and cocaine gem. Set PaperClip version: 3.4.1 Set Cocaine version: 0.5.

I faced the same problem and my issue was already there in paperclip gem github issues

查看更多
可以哭但决不认输i
3楼-- · 2020-06-30 05:42

Just for the record:

brew uninstall libtool
brew install libtool
brew uninstall jpeg
brew install jpeg
brew link --overwrite jpeg
brew unlink freetype && brew link freetype
查看更多
家丑人穷心不美
4楼-- · 2020-06-30 05:43

I had similar issue, but older PaperClip (3.0.2).

In my case I fixed it with:

gem 'cocaine', '0.3.2'
查看更多
放荡不羁爱自由
5楼-- · 2020-06-30 05:44

Reinstalling libtool brew install libtool worked for me.

查看更多
看我几分像从前
6楼-- · 2020-06-30 05:54

I just solved this issue. brew makes a directory call Cellar, /usr/local/Cellar Verify if you don`t have two ImageMagick, i had one named ImageMagick-Ruby182, so, if you have it run brew uninstall ImageMagick-Ruby182, and also the normal imagemagick, and reinstall image magic.

查看更多
啃猪蹄的小仙女
7楼-- · 2020-06-30 05:56

I have the same issue, and I solved it, when i configure the dynamic linker run-time bindings to create the necessary links and cache to the most recent shared libraries using the ldconfig command.

So you need to use the following command:

sudo ldconfig /usr/local/lib

Actually, I advice to re-install imagemagick using steps at how-to-install-image-magick-and-setup-paperclip.

查看更多
登录 后发表回答