2012-04-16 225 views
0

我正在使用carrierwave将图像上传到我的项目,以及Ryan Bates的railscasts here无法安装gem rmagick [Windows 7 64位]

我使用红宝石1.9.2p290(2011-07-09)[I386-的mingw32]和轨道3.1.0

在这里面,才能有使用rmagick您必须安装它在说情节你的Gemfile像这样

的Gemfile

gem 'rmagick' 

,然后运行bundle安装我的错误

Installing rmagick (2.13.1) with native extensions C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR 
: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) 

    C:/Ruby192/bin/ruby.exe extconf.rb 
checking for Ruby version >= 1.8.5... yes 
Invalid drive specification. 
Unable to get ImageMagick version 
*** extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more 
details. You may need configuration options. 

Provided configuration options: 
    --with-opt-dir 
    --without-opt-dir 
    --with-opt-include 
    --without-opt-include=${opt-dir}/include 
    --with-opt-lib 
    --without-opt-lib=${opt-dir}/lib 
    --with-make-prog 
    --without-make-prog 
    --srcdir=. 
    --curdir 
    --ruby=C:/Ruby192/bin/ruby 

所以我用Google搜索了无法获取ImageMagick的版本,发现这个链接here和遵循的方向,下载RMagick-2.13.1.tar.gz,解压到C:\ rmagick,并运行

ruby setup.rb command 

和出现以下错误。

c:\RMagick-2.13.1>ruby setup.rb 
---> lib 
---> lib/rvg 
<--- lib/rvg 
<--- lib 
---> ext 
---> ext/RMagick 
C:/Ruby192/bin/ruby.exe c:/RMagick-2.13.1/ext/RMagick/extconf.rb 
checking for Ruby version >= 1.8.5... yes 
Invalid drive specification. 
Unable to get ImageMagick version 
*** c:/RMagick-2.13.1/ext/RMagick/extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of 
necessary libraries and/or headers. Check the mkmf.log file for more 
details. You may need configuration options. 

再次,错误无法获取ImageMagick版本。我认为Imagemagick与Windows安装捆绑在一起。任何人在这件事情上有任何帮助?

回答

3

CarrierWave确实是一款用于管理Rails中图片上传的优秀解决方案。 RMagick功能非常强大,但您不会相信这么多年来我和朋友们在各种环境和操作系统(尤其是Windows和Mac)中安装和升级RMagick和ImageMagick时遇到的困难。

如果您安装了ImageMagick,并且您不担心太多性能问题,则可以使用MiniMagick而不是RMagick。安装它更容易。在你上传类,你可以包括MiniMagick:

class MyUploader < CarrierWave::Uploader::Base 
    include CarrierWave::MiniMagick 

    ... 
end 

此的图像处理工具的复杂性是我建议你看一看我们的,而所有的图像转换是在云中完成整合CarrierWave解决方案的原因之一(根本不需要安装RMagick或ImageMagick)。 This blog post描述了解决方案。只需切换您包含的CarrierWave插件:

class MyUploader < CarrierWave::Uploader::Base 
    include Cloudinary::CarrierWave 

    ... 
end 
+0

太棒了。我在看minimagick,但决定尝试和强硬。我会接受你的建议,并在这一个上放弃RMagick。 – ruevaughn 2012-04-27 03:09:04