【被网上巨坑了】 win10+php5.6-ts-vc11-x64配置imagick的经历
前言
项目需要,需要用到imagick,恰好开发机器是win10,而php是5.6+ts+vc11+x64,于是入坑,配置imagick。
请注意,网上一大堆的可能都是假的,请按照下面步骤做。
imagemagick安装
imagemagick的版本是一个非常大的问题,在网上能够找到的资源我试过了很多,能够正常运行的都会出现warning表示版本不匹配,譬如这个:
但不影响正常使用,我本机环境采用的是:
我后面会打包一下给大家下载的。
安装完毕以后,环境变量已经帮你配置了还要加一个magick_home变量
如下图:
测试是否可以运行:
好了,我们默认可以用了。
php – imagick dll下载及配置
dll可以用的3.4.3rc1—反正是stable,我用的是这个。没问题。
将所有dll都放到php的ext里面去。
那么好了,开服务器测试一下:
用原有的图片缩略图程序来测试一下:
请注意,原有的是有错的,主要是需要将图片路径变成绝对路径。。。还有就是,请添加上一张test.png图片,我后面会直接打包给各位尝试的。程序改成这样子:
<?php /* A simple example demonstrate thumbnail creation. */ /* Create the Imagick object */ $im = new Imagick(); /* Read the image file */ $im->readImage( '绝对路径啊,亲/tmp/test.png' ); /* Thumbnail the image ( width 100, preserve dimensions ) */ $im->thumbnailImage( 100, null ); /* Write the thumbail to disk */ $im->writeImage( '绝对路径啊,亲/tmp/th_test.png' ); /* Free resources associated to the Imagick object */ $im->destroy(); ?>
然后看看结果:
好了,现在可以正常运行了。感动啊。。。
相关资源下载
http://www.imagemagick.org/download/binaries/
http://windows.php.net/downloads/pecl/releases/imagick/