windows下安装php_imagick拓展

php中文网
发布: 2016-06-20 13:01:38
原创
1131人浏览过

最近项目中需要用到图片的一些特殊处理——比如:根据用户请求生成任意尺寸的图像。经过一些资料的查找,最终选用了php_imagick。利用imagemagick,你可以根据web应用程序的需要动态生成图片, 还可以对一个(或一组)图片进行改变大小、旋转、锐化、减色或增加特效等操作,并将操作的结果以相同格式或其它格式保存。本节我们就来介绍一下如何在windows下安装php_imagick拓展。

1. 下载 Download ImageMagick

#下载页面:

http://www.imagemagick.org/script/binary-releases.php#windows

#直接下载:

http://www.imagemagick.org/download/binaries/ImageMagick-6.6.3-0-Q16-windows-dll.exe

立即学习PHP免费学习笔记(深入)”;

2. 安装 Install ImageMagick

安装路径随意,我的安装是:

D:\WampServer\bin\ImageMagick-6.6.3-Q16

3. 测试 Testing the Installation

如果不加入环境变量的话,可以先下面方式测试:
Open the command prompt (Run->”CMD”->ENTER) and type in convert and press enter. You should see the help parameters of convert

cd D:\WampServer\bin\ImageMagick-6.6.3-Q16 # 回车
D:\WampServer\bin\ImageMagick-6.6.3-Q16>convert
Version: ImageMagick 6.6.3-0 2010-07-01 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

Usage: Magick [options ...] file [ [options ...] file ...] [options ...] file

Image Settings:
  -adjoin              join images into a single multi-image file
  -affine matrix       affine transform matrix
  -alpha option        activate, deactivate, reset, or set the alpha channel
  -antialias           remove pixel-aliasing
  -authenticate password
                       decipher image with this password
  -attenuate value     lessen (or intensify) when adding noise to an image
  -background color    background color
  -bias value          add bias when convolving an image
  -black-point-compensation
                       use black point compensation
  -blue-primary point  chromaticity blue primary point
  -bordercolor color   border color
  -caption string      assign a caption to an image
.......
......
......
登录后复制

加入环境变量,方便以后使用(我的是WIndows7 系统):
我的电脑-》右键属性-》高级系统设置-》高级-》环境变量-》系统变量-》
-》找到Path, 点击编辑加入:

D:\WampServer\bin\ImageMagick-6.6.3-Q16;

加入完成之后,可以直接在命令行(CMD)使用convert了。

帮衣帮-AI服装设计
帮衣帮-AI服装设计

AI服装设计神器,AI生成印花、虚拟试衣、面料替换

帮衣帮-AI服装设计 106
查看详情 帮衣帮-AI服装设计

4. 下载DLL Downloading the php_Imagick.dll

Again the version problem, well if you are using PHP 5.2.x this is where you will get your dll.

我使用的是 (php5.2.9-2):php_imagick_dyn-Q16.dll

dyn = dynamic, st = static, q16 = 16 bit, q8= 8 bit. This should match your downloaded version of course. If you downloaded q16 dynamic library, your file will be php_imagick_dyn-Q16.dll

If you are using PHP 5.3.x, this is your location to download.

5. 编辑 PHP.ini

下载的php_imagick_dyn-Q16.dll保存到

D:\WampServer\bin\php\php5.2.9-2\ext\

然后编辑 PHP.ini
找到dll这里,加入下面的最后一行:

;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll
extension=php_imagick.dll
登录后复制

6. 重启Wamp

7. 通过查看phpinfo();

如果有imagick项应该成功了

8. 小测试

$im = new imagick( 'a.jpg' );
// resize by 200 width and keep the ratio
$im->thumbnailImage( 200, 0);
// write to disk
$im->writeImage( 'a_thumbnail.jpg' );
登录后复制

好了,完成了。


PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号