php imagemagick 配置

最近需要在项目中用到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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值