上传时Paperclip :: Errors :: NotIdentifiedByImageMagickError错误

时间:2016-03-31 08:26:16

标签: ruby-on-rails ruby-on-rails-4 imagemagick paperclip imagemagick-convert

我正在尝试使用Jcrop裁剪图像,我在上传图像时发送裁剪参数。我的模型代码看起来像这样

has_attached_file :image, styles: { medium: "500x500>", thumb: "100x100>", large: "700x700>" }, default_url: "/images/:style/missing.png", :processors => [:cropper]
  validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/

  after_create :reprocess_image, if: :cropping?

  def cropping?
    !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank?
  end

  def avatar_geometry(style = :original)
    @geometry ||= {}
    @geometry[style] ||= Paperclip::Geometry.from_file(image.path(style))
  end

  private

  def reprocess_image
    ratio = avatar_geometry.width.to_f / avatar_geometry(:large).width.to_f
    self.crop_x = (crop_x * ratio).round
    self.crop_y = (crop_y * ratio).round
    self.crop_w = (crop_w * ratio).round
    self.crop_h = (crop_h * ratio).round

    image.assign(image)
    image.save
  end

但我在paperclip行中收到了以下Paperclip::Geometry.from_file(image.path(style))错误,

Command :: PATH=/usr/local/bin/:$PATH; identify -format '%wx%h,%[exif:orientation]' '/home/rajdeepb/projects/ror/demo/Tettares_ROR/public/system/event_attachements/images/000/000/017/original/5993_604345376383295_8200271052700075298_n.jpg[0]' 2>/dev/null
Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError
from /home/rajdeepb/.rvm/gems/ruby-2.2.4@tror/gems/paperclip-4.3.5/lib/paperclip/geometry_detector_factory.rb:10:in `make'

我已尝试过在StackOverflow上发布的各种解决方案,但没有任何效果。

我正在使用以下版本的Paperclip和依赖宝石。

paperclip (4.3.5)
  activemodel (>= 3.2.0)
  activesupport (>= 3.2.0)
  cocaine (~> 0.5.5)
  mime-types
  mimemagic (= 0.3.0)

我已经跟踪this railscasts会话来实现这一点。

请帮助,任何线索都会被高度关注。

感谢。

0 个答案:

没有答案