結局 paperclip を使ってみることにした

要はDBに入れたいのだが、豊富なコールバックが用意されているので、小細工で
どうにかなるだろう。


$ bundle install
Fetching source index for http://rubygems.org/
:
:
Installing rmagick (2.13.1) with native extensions /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/kageyu/bin

と言われた・・・
Magick-config なんてどのパッケージに入ってんだろ。
とりあえず、ImageMagick を最新版にする。

$ sudo yum list | grep ImageMagick
すると入ってるけど、最新版が出ているよという

ImageMagick.i386 6.2.8.0-4.el5_5.3 updates
ImageMagick-c++.i386 6.2.8.0-4.el5_5.3 updates
ImageMagick-c++-devel.i386 6.2.8.0-4.el5_5.3 updates
ImageMagick-devel.i386 6.2.8.0-4.el5_5.3 updates
ImageMagick-perl.i386 6.2.8.0-4.el5_5.3 updates
sudo yum install ImageMagick ImageMagick-devel でアップデートすると、結構沢山のパッケージを必要としていることがわかった。

==========================================================================================
Package Arch Version Repository Size
==========================================================================================
Installing:
ImageMagick-devel i386 6.2.8.0-4.el5_5.3 updates 74 k
Installing for dependencies:
ghostscript-devel i386 8.15.2-9.12.el5_5 updates 41 k
lcms-devel i386 1.18-0.1.beta1.el5_3.2 base 156 k
libICE-devel i386 1.0.1-2.1 base 13 k
libSM-devel i386 1.0.1-3.1 base 9.4 k
libXt-devel i386 1.0.2-3.2.el5 base 330 k
Updating for dependencies:
ghostscript i386 8.15.2-9.12.el5_5 updates 5.9 M
libXt i386 1.0.2-3.2.el5 base 173 k
仕方がないので、インストール。
すると、Magic-config が入っている。
どれどれと確認すると、

$ rpm -qf `which Magick-config`
ImageMagick-devel-6.2.8.0-4.el5_5.3
なるほど ImageMagick-devel のアップデートも必要だったか。
そして再度、bundle install を行う。


Installing rmagick (2.13.1) with native extensions /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes

Warning: Found a partial ImageMagick installation. Your operating system likely has some built-in ImageMagick libraries but not all of ImageMagick. This will most likely cause problems at both compile and runtime.
Found partial installation at: /usr
checking for ImageMagick version >= 6.4.9... no
Can't install RMagick 2.13.1. You must have ImageMagick 6.4.9 or later.

をいorz
確認してみると ImageMagick のバージョンは 6.2.8。
仕方ないので、ここから手動で上書きインストール
root になって wget してきてインストール。

[root@apps ImageMagick-6.6.7-1]# ./configure --prefix=/usr
:
ImageMagick is configured as follows. Please verify that this configuration
matches your expectations.

Host system type: i686-pc-linux-gnu
Build system type: i686-pc-linux-gnu

Option Value

                                                                                                                                                            • -

Shared libraries --enable-shared=yes yes
Static libraries --enable-static=yes yes
Module support --with-modules=no no
GNU ld --with-gnu-ld=yes yes
Quantum depth --with-quantum-depth=16 16
High Dynamic Range Imagery
--enable-hdri=no no

Delegate Configuration:
BZLIB --with-bzlib=yes yes
Autotrace --with-autotrace=no no
Dejavu fonts --with-dejavu-font-dir=default none
DJVU --with-djvu=yes no
DPS --with-dps=yes no
FFTW --with-fftw=yes no
FlashPIX --with-fpx=yes no
FontConfig --with-fontconfig=yes no
FreeType --with-freetype=yes yes
GhostPCL None pcl6 (unknown)
GhostXPS None gxps (unknown)
Ghostscript None gs (8.15.2)
Ghostscript fonts --with-gs-font-dir=default /usr/share/fonts/default/Type1/
Ghostscript lib --with-gslib=no no
Graphviz --with-gvc=yes no
JBIG --with-jbig=yes no
JPEG v1 --with-jpeg=yes yes
JPEG-2000 --with-jp2=yes no
LCMS v1 --with-lcms=yes yes
LCMS v2 --with-lcms2=yes no
LQR --with-lqr=yes no
LZMA --with-lzma=yes no
Magick++ --with-magick-plus-plus=yes yes
OpenEXR --with-openexr=yes no
PERL --with-perl=no no
PNG --with-png=yes yes
RSVG --with-rsvg=yes no
TIFF --with-tiff=yes yes
Windows fonts --with-windows-font-dir= none
WMF --with-wmf=yes no
X11 --with-x= yes
XML --with-xml=yes yes
ZLIB --with-zlib=yes yes

X11 Configuration:
X_CFLAGS =
X_PRE_LIBS = -lSM -lICE
X_LIBS =
X_EXTRA_LIBS =

Options used to compile and link:
PREFIX = /usr
EXEC-PREFIX = /usr
VERSION = 6.6.7
CC = gcc -std=gnu99 -std=gnu99
CFLAGS = -fopenmp -g -O2 -Wall -pthread
CPPFLAGS = -I/usr/include/ImageMagick
PCFLAGS = -fopenmp
DEFS = -DHAVE_CONFIG_H
LDFLAGS =
MAGICK_LDFLAGS = -L/usr/lib
LIBS = -lMagickCore -llcms -ltiff -lfreetype -ljpeg -lpng -lXext -lXt -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lm -lgomp -lpthread
CXX = g++
CXXFLAGS = -g -O2 -pthread
FEATURES = OpenMP

だそうだ。
zlib xml jpeg png があれば良いので、他は入ってなくてもいい。
無事に

[root@apps ImageMagick-6.6.7-1]# make && make install
:
:
[root@apps ImageMagick-6.6.7-1]# Magick-config --version
6.6.7 Q16
と新しくなっていることを確認。
再度、

$ bundle install
Fetching source index for http://rubygems.org/
:
Installing rmagick (2.13.1) with native extensions
:
はいった!

だが、しかし、なぜだ?
動いてくれない・・・orz

ここではきちんと動いている。
http://d.hatena.ne.jp/shunsuk/20110107/1294390187

ログには [paperclip] Saving attachments. と出ているので、あと少しなんだが・・・

とりあえず、結局自分で処理することにしたorz※2

※2