(1)yum安装ImageMagick


yum install ImageMagick ImageMagick-devel


(2)测试是否安装成功


[root@localhost]# convert -version
Version: ImageMagick 6.2.8 05/07/12 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC


(3)安装imagick扩展


wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz
tar xzvf imagick-3.1.0RC2.tgz
cd imagick-3.1.0RC2
phpize
./configure
make
make install


(4)编辑php.ini文件,在文件末尾添加如下代码


extension=imagick.so


(5)重新启动apache服务器


service httpd restart


(6)imagick扩展使用范例


header('Content-type: p_w_picpath/png');
$files = '/var/test/test.png';
$p_w_picpath = new \Imagick($files);
$p_w_picpath->thumbnailImage(200, 100, true);
echo $p_w_picpath;

thumbnailImage()第三个参数表示Whether to force maximum values

imagick的类详见:http://www.php.net/manual/en/class.imagick.php