ImageMagickの最新版とRMagickをWindowsにインストールする(ImageMagick 6.9.1, RMagick 2.15.4, Ruby 2.2.2)


RMagickruby使ImageMagickRMagickImageMagick使ImageMagick使

 

RubyImageMagick使

 

1.Rubyをインストールします

RubyInstallerのダウンロードページから最新版(今回は Ruby 2.2.2 (x64) )を落としてきてインストールします。途中で「Rubyの実行ファイルへ環境変数PATHを設定する」というオプションが出てくるので、チェックしておきます。

ちなみにActiveScriptRubyだとDevKitがないので今回の方法ではRMagickのインストールができません。残念。

2.DevKitを入れます


RubyInstallerDevKit Development Kit  For use with Ruby 2.0 and above (x64 - 64bits only) 

DevKit C:¥DevKit 

Ruby  RubyDevKitRuby
cd C:¥DevKit
ruby dk.rb init
ruby dk.rb install

OK

 

3.ImageMagickをインストールする


ImageMagick

ImageMagick Looking for the latest version? 



f:id:slideglide:20150815042407p:plain
2Add application...4Install development...1

 

4.convertコマンドのチェック


Ruby 2
convert -v


By default, the image format of `file' is determined by its magic
number.  To specify a particular image format, precede the filename
with an image format name and a colon (i.e. ps:image) or specify the
image type as the filename suffix (i.e. image.ps).  Specify 'file' as
'-' for standard input or output.

OK

convertImageMagickconvertWindowsgem使Windows

PATHImageMagick

 

5.gemのインストール



gem install rmagick -- '--with-opt-dir="c:\Program Files\ImageMagick-6.9.1-Q16-HDRI"'


Fetching: rmagick-2.15.4.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-dir="c:\Program Files\ImageMagick-6.9.1-Q16-HDRI"'
This could take a while...
Successfully installed rmagick-2.15.4
Parsing documentation for rmagick-2.15.4
Installing ri documentation for rmagick-2.15.4
Done installing documentation for rmagick after 12 seconds
1 gem installed



--platform=ruby 
gem install rmagick --platform=ruby -- '--with-opt-dir="c:\Program Files\ImageMagick-6.9.1-Q16-HDRI"'

 

6.動作確認

require 'RMagick'
include Magick
f = Image.new(100,100) { self.background_color = "red" }
f.write("square.gif")

.rb square.gif 
ruby test.rb

f:id:slideglide:20150815044733g:plain  


f:id:slideglide:20150815051010j:plain

RMagick ImageMagick 6.9.1  RMagick 2.15.4