您的位置:首页 > 编程语言 > PHP开发

php imagemagick 配置

2016-07-29 00:00 447 查看
最近需要在项目中用到ImageMagick来对上传的图片做多图处理,在配置上遇到些问题,Windows7与Ubuntu上均不可能一次完美安装,不过在Linux下调来调去的比较有意思,所以在Ubuntu下查了不少东西,记录了其中几个比较关键的问题。

1. 先装ImageMagick

下载ImageMagick http://www.imagemagick.org/ wget ftp://ftp.u-aizu.ac.jp/pub/graphics/image/ImageMagick/imagemagick.org/ImageMagick-6.6.5-10.tar.gz tar -xzvf ImageMagick-6.6.5-10.tar.gz
./configure -prefix=/usr/local/ImageMagick -disable-openmp(没加在ubuntu下重启php可能会出错)
make && make install

2. 再装Imagick

wget http://pecl.php.net/get/imagick-3.0.1.tgz tar -xzvf imagick-3.0.1.tgz
cd imagick-3.0.1
phpize

//phpize是一个shell脚本,主要是用来进行编译环境的准备,执行以后会生成一些新的文件,为配置、编译及安装作好准备

使用./configure --help 查看配置选项
./configure --with-php-config=/usr/local/php5/bin/php-config --with-imagick=/usr/local/ImageMagick

In the step, we should edit the file imagick-3.1.0RC2/config.m4 line number 55.

Make changes like this, from

if test -r $WAND_DIR/include/ImageMagick/wand/MagickWand.h;

to

if test -r $WAND_DIR/include/ImageMagick-6/wand/MagickWand.h;

Note this difference made in the imagick version number. After that try the conventional installation procedures

cd imagick-3.1.0RC2
phpize
./configure
make
make install

php配置
extension=imagick.so

如此搞定。

测试如下:

<?php
$im = new imagick( 'b.jpg' );
// resize by 200 width and keep the ratio
$im->thumbnailImage( 100, 0);
// write to disk
$im->writeImage( 'b_thumbnail.jpg' );
?>

特此记录,也希望对看到的同学有所帮助。

相关链接:
http://stackoverflow.com/questions/17836893/imagemagick-pecl-issue-cannot-locate-header-file-magickwand-h http://hi.baidu.com/q1225904052/item/05b92fe58c56392a86d9de4a http://blog.csdn.net/swingpyzf/article/details/8923899 http://www.imagemagick.org/script/install-source.php#unix
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: