【问题标题】:Photo Failed to manipulate with MiniMagick, maybe it is not an image? error照片 使用 MiniMagick 操作失败,可能不是图像?错误
【发布时间】:2013-02-18 11:04:26
【问题描述】:

我有以下代码,它调整大小和图像,然后添加一些十六进制背景。在本地主机上这有效,但在 heroku 上我收到以下错误

version :big do
  process :offer_resize_and_pad
 end

def offer_resize_and_pad
  img = resize_and_pad(600, nil, model.hex, 'Center')
  img
end

"Photo Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: Command (\"mogrify -thumbnail \"600x>\" -background \"#fff\" -gravity \"Center\" -extent \"600x\" /tmp/mini_magick20130217-2-1hts61y.jpg\") failed: {:status_code=>1, :output=>\"mogrify: Empty JPEG image (DNL not supported)/tmp/mini_magick20130217-2-1hts61y.jpg'@jpeg.c/EmitMessage/232.\n\"

【问题讨论】:

  • 这可能是因为您对 Heroku 上的文件系统的访问权限与您在本地计算机(即 /tmp 目录)上的访问权限不同。
  • 你说得有道理。但是,我该如何解决这个问题? .还有来自其他上传者的其他图片,这很有效。
  • 当我将我的 Gemfile 从 mini_magick (4.0.1) 更新到 (4.3.6) 时出现类似错误,请参阅 github.com/minimagick/minimagick/issues/338

标签: ruby-on-rails ruby-on-rails-3 heroku minimagick


【解决方案1】:

我使用了 RMagick 而不是 Mini_magick,并进行了一些语法更改,它似乎可以工作 :)。

include CarrierWave::RMagick

def offer_resize_and_pad
  img = resize_and_pad(600, 280, model.hex, ::Magick::CenterGravity)
  img
end

【讨论】:

  • 请扩展您的答案。为了使答案对未来的访问者有所帮助,您应该发布最终对您有用的解决方案。
猜你喜欢
  • 2017-01-27
  • 2012-06-04
  • 2016-04-12
  • 2020-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-12
相关资源
最近更新 更多