2013-02-18 42 views
1

我有以下代码,调整大小和图像,然后添加一些十六进制背景。在localhost这个工作,但在Heroku我得到以下错误照片无法操作MiniMagick,也许它不是一个图像?错误

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 \”

+0

这可能是因为你没有相同的访问文件系统在Heroku上,你就做你的本地机器即/ tmp目录 – Yule 2013-02-18 11:41:12

+0

你有一点,但是,我该如何解决这个问题?还有其他来自其他上传者的图片,这是工作。 – vladCovaliov 2013-02-18 11:46:00

+0

当我将我的Gemfile从mini_magick(4.0.1)更新到(4.3.6)时,出现类似的错误,请参阅https://github.com/minimagick/minimagick/issues/338 – vanboom 2015-11-21 17:00:38

回答

0

我以前用过RMagick代替Mini_magick,有一些语法变化,似乎工作:)。

include CarrierWave::RMagick 

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

请扩展您的答案。为了让答案对未来的访问者有所帮助,你应该发布最终为你工作的解决方案。 – andr 2013-02-18 12:19:13

相关问题