バージョンの選択
今回のプロジェクトではRuby 1.9 + Rails 3を使うことが決定しています。http://rmagick.rubyforge.org/によると、RMagick 2がRuby 1.9に対応しているようです。また、ImageMagick 6.3.5以降にも対応しています。そこで、それぞれ最新版(ImageMagick 6.7.2-7 + RMagick 2.13.0)を使うことにします。
There are two versions of RMagick, RMagick 1 and RMagick 2. Most people will want to install RMagick 2. This version works with Ruby 1.8.5 and later (including Ruby 1.9) and ImageMagick 6.3.5 and later. All new enhancements to RMagick will be in RMagick 2. RMagick 2 does not work with GraphicsMagick.
http://rmagick.rubyforge.org/
ImageMagick
インストール
# cd /usr/local/src # wget ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick-6.7.2-8.tar.gz # tar zxvf ImageMagick-6.7.2-8.tar.gz # cd ImageMagick-6.7.2-8 # ./configure --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=$FONTS
ダウンロードできないときは、Download @ ImageMagickから近くのミラーサイトを探してください。
makeを実行する前に./configureの結果を確認します。ホスト環境とビルド環境が実環境と一致していることを確認します。
ImageMagick is configured as follows. Please verify that this configuration matches your expectations. Host system type: x86_64-unknown-linux-gnu Build system type: x86_64-unknown-linux-gnu
またDelegate Configuration
セクションで、必要な機能が有効になっていることを確認します。よく使う機能を以下に示します。JPEG, GIF, PNGをサポートしたい場合は、JPEG v1, PNG, ZLIBがyesになっている必要があります。
BZLIB --with-bzlib=yes yes # bzipサポート FreeType --with-freetype=yes yes # freetypeサポート JPEG v1 --with-jpeg=yes yes # JPEGサポート JPEG-2000 --with-jp2=yes no # JPEG2000サポート PNG --with-png=yes yes # PNGサポート TIFF --with-tiff=yes no # TIFFサポート XML --with-xml=no no # XMLサポート ZLIB --with-zlib=yes yes # zipサポート
必要な機能が足りないときは、ライブラリを追加インストールしてからもう一度./configureを実行します。
# yum install libjpeg.x86_64 libjpeg-devel.x86_64 # yum install libpng.x86_64 libpng-devel.x86_64 # yum install giflib.x86_64 giflib-devel.x86_64 # yum install libxml2.x86_64 libxml2-devel.x86_64 # yum install libxslt.x86_64 libxslt-devel.x86_64 # yum install zlib.x86_64 zlib-devel.x86_64 # yum install freetype.x86_64 freetype-devel.x86_64
./configureの結果に問題がなければ、make & make installを実行します。
# make # make install
対応しているフォーマットの一覧に、目的の画像フォーマットがあることを確認します。
# convert -list format
ロードパスの追加
ld.so.confに/usr/local/libディレクトリを追記します。
FILE: /etc/ld.so.conf --- /etc/ld.so.conf 2011-09-24 11:58:10.000000000 +0900 +++ /etc/ld.so.conf 2011-09-24 11:56:39.000000000 +0900 @@ -1,2 +1,3 @@ include ld.so.conf.d/*.conf include /usr/lib +include /usr/local/lib
ロードパスの修正をその場で反映させるため、ldconfigコマンドを実行します。
# ldconfig
RMagick
インストール
# gem install rmagick --no-ri --no-rdoc