carrierwave + mini_magick gems = not an image error

旧街凉风 提交于 2019-11-27 05:58:17

问题


I'm using:

- carrierwave 0.6.0
- rails 3.2.1
- mini_magick 3.4
- ruby 1.9.2p290

And during image uploading I want to resize uploading pic:

(image_uploader.rb)
process :resize_to_fit => [200, 200]

But after image uploading I've got an error:

1 error prohibited this organization from being saved:
Image image Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: MiniMagick::Invalid

PS. If I'm not resizing, image upload works fine.

PS2. I tried to add in config/environment.rb:

require 'rubygems'
require "mini_magick"

but without success (still not working - btw. is it required when using mini_magick as a gem?)


回答1:


I'm sure that you've solved this by now (at least hopefully! It's almost two months later!), but here's a solution that worked for me just now:


Uninstall imagemagick through homebrew:

  • brew uninstall imagemagick

Clean your homebrew directory:

  • brew cleanup --force -s
  • --force removes all out of date keg-only brews, -s removes all cached downloads

Reinstall imagemagick:

  • brew install imagemagick

After all of that, you should be good to go!




回答2:


B. Ruschill's answer seemed to have solved many peoples' problem, unfortunately it didn't for me. Nor did many solutions I found on the internets.

Turns out I had an outdated version of libjpeg. I fixed that by removing and re-installing using brew. This may happen for other image formats too. Perhaps doing the same for the respective libs might solve the problem.

TL;DR

brew remove libjpeg
brew install libjpeg


来源:https://stackoverflow.com/questions/9905499/carrierwave-mini-magick-gems-not-an-image-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!