2012-04-16 222 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