肉とビールとパンケーキ by @sotarok

少し大人になった「肉とご飯と甘いもの」

ImagickのroundCornersを使うための旅(成功編)(CentOS 5.2にImageMagick 6.4.3をインストール)


ImagickのroundCornersを使うための旅(失敗編) の続きです。


そんなわけで、ImageMagickをソースからインストールすることに決定しました。

ImageMagick 6.4.3 のインストール

ImageMagick: Install from Sourceから、ImageMagick.tar.gz をダウンロードしてきます。

そんで、

% ./configure

すると、

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=yes            yes
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=yes          no
DJVU              --with-djvu=yes               no
DPS               --with-dps=yes                no
FlashPIX          --with-fpx=yes                no
FontConfig        --with-fontconfig=yes         yes
FreeType          --with-freetype=yes           yes
GhostPCL          None                          pcl6 (unknown)
GhostXPS          None                          gxps (unknown)
Ghostscript       None                          gs (8.15.2)
result_ghostscript_font_dir='none'
Ghostscript fonts --with-gs-font-dir=default    
Ghostscript lib   --with-gslib=yes              yes
Graphviz          --with-gvc=yes                no
JBIG              --with-jbig=yes               no
JPEG v1           --with-jpeg=yes               yes
JPEG-2000         --with-jp2=yes                no
LCMS              --with-lcms=yes               yes
LQR               --with-lqr=yes                no
Magick++          --with-magick-plus-plus=yes   yes
OpenEXR           --with-openexr=yes            yes
PERL              --with-perl=yes               /usr/bin/perl
PNG               --with-png=yes                yes
RSVG              --with-rsvg=yes               no
TIFF              --with-tiff=yes               yes
result_windows_font_dir='none'
Windows fonts     --with-windows-font-dir=      
WMF               --with-wmf=yes                no
X11               --with-x=                     yes
XML               --with-xml=yes                no
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/local
  EXEC-PREFIX     = /usr/local
  VERSION         = 6.4.3
  CC              = gcc -std=gnu99
  CFLAGS          = -fopenmp -g -O2 -Wall -W -pthread
  MAGICK_CFLAGS   = -fopenmp -g -O2 -Wall -W -pthread
  CPPFLAGS        = -I/usr/local/include/ImageMagick
  PCFLAGS         = -fopenmp
  DEFS            = -DHAVE_CONFIG_H
  LDFLAGS         = -lfreetype
  MAGICK_LDFLAGS  = -L/usr/local/lib -lfreetype
  LIBS            = -lMagickCore -llcms -ltiff -lfreetype -ljpeg -lfontconfig -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lgomp -lpthread 
  CXX             = g++
  CXXFLAGS        = -g -O2 -Wall -W -pthread

とかわーっと出ます。
エラーナシ。やったー。

で、インストール。

% make
% make install 

これが結構長いです。ここらで風呂に入ります。
戻ってきたら、特にエラーも出ませんでした。インストール完了したら、確認。

% convert --version
Version: ImageMagick 6.4.3 2008-08-22 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC

しゃー。つか6.4.3て出たばっかりじゃん。超最新。バッチリですね!!(でもどうせすぐ古くなるんだよな・・・ImageMagickの進化スピード速すぎ *1

PECLからインストールしなおし


ImageMagickが古いときにPECLでインストールされたものは使えないので(PECLのインストーラは実際は phpize, configure, make, make installするだけなので、インストールした時点での環境で拡張が作られてしまいます)、インストールのしなおし。

% sudo pecl uninstall imagick
% sudo pecl install imagick

そしたら、無事にインストールすることができました。

動作の確認

サンプル。
これは、今日Cafe comme caで食ったキャラメルバナーヌ。本編には関係ないですがかなりおいしいです。

<?php
$Img = new Imagick("cake.jpg");
$Img->roundCorners(20, 20);

$Img->writeImage("cake_round.jpg");
$Img->destroy();

角丸前。

角丸後。


(ここまで色々戦っててつかれていたので、背景キャンバスつくって白背景にしてーとかメンドくてやってられっかボケー!と思ったのでその辺は割愛)

まとめ

  • 最初からソースでインストールするのが間違いない
  • それが嫌なら自分でrpmでも作っておく
  • ブログにエラーからすべて思考プロセスを掲載するのはなかなか大変
  • Imagick、おいしいです
  • ほかにも色々書きたいネタはあるのだが。。。

おまけ

今回調べてるときにタブだしまくってたよーというお話(さらに上下にImagickとは関係ないやつが2段ずつあった)

*1:[http://www.imagemagick.org/script/changelog.php:title=http://www.imagemagick.org/script/changelog.php]