search
HomeBackend DevelopmentPHP Tutorialwindows7下安装php的imagick和imagemagick扩展教程_PHP

最近的PHP项目中,需要用到切图和缩图的效果,在linux测试服务器上很轻松的就安装好php imagick扩展。但是在本地windows开发环境,安装过程遇到好多问题,在此与大家分享。

1. 下载 ImageMagick
下载地址:http://imagemagick.org/script/binary-releases.php#windows

下载最新版本,ImageMagick-6.8.6-9-Q16-x86-dll.exe

2. 安装 ImageMagick
安装 ImageMagick 到 PC 上。安装路径不能出现空格,否则无法使用。安装时,一点选中把执行路径添加到 path 上,否则你就得手动去添加 path 路径了。

3. 测试安装
打开windows 命令行窗口(win+r -> “cmd” -> Enter),输入convert,回车。会出现convert的帮助文档,如果没有出现,说明没有安装成功,或没有把安装目录添加到环境变量 path 中。

添加到环境变量,如我的 ImageMagick 安装目录是 c:/imagemagick。

添加过程:
我的电脑 -> 右键点击 -> 高级系统设置 -> 高级 -> 环境变量 -> 系统变量 -> path -> 选择并编辑 -> 把你的安装目录,添加到其中

4. 下载 php扩展 php_imagick.dll


php5.4.x or php5.5.x 下载地址 http://www.peewit.fr/imagick/

dyn = dynamic, st = static, q16 = 16 bit, q8= 8 bit.

以上标识,同你下载的ImageMagick下载标识相同,本人用的是q16

5. 把dll文件重命名为php_imagick.dll,并放到php 扩展文件目录 php/ext 中。

6. 在 php.ini 配置文件中添加,extension=php_imagick.dll。

7. 重启电脑,只重启apache不管用的情况下,重启下PC。因为扩展底层使用的是imageMagic软件,所以软件重启电脑,重新加载软件,并刷新path路径。

8. 重启后,打开 phpinfo页面,查看,扩展已经安装成功。如果还未安装成功,极有可能imagemagick软件版本过高,请选择更低一级的版本安装。

9. PHP测试代码。

<&#63;php
$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' );

10. 查看手册,学习API

相关扩展学习手册地址 http://uk3.php.net/manual/zh/book.imagick.php 手册中包含大量易用实例。

这里还有查看命令行参数的文档 http://www.imagemagick.org/Usage/

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

windows7内部版本7601副本不是正版 内部版本7601副本不是正版最简单解决方法windows7内部版本7601副本不是正版 内部版本7601副本不是正版最简单解决方法Mar 15, 2024 pm 09:49 PM

最近有小伙伴反映自己的电脑提示“windows7内部版本7601副本不是正版”,都想知道win7副本不是正版7601影响使用吗,这原因主要是用户的系统是没有进行激活,今天小编就来给的大家讲一讲内部版本7601副本不是正版最简单解决方法,有需要的朋友可以来看看。windows7内部版本7601副本不是正版方法一:1、键盘同时按“win+r”,然后输入“CMD”,再按“回车”确定。2、在弹出的窗口中输入“SLMGR-REARM”,注意中间有一个空格,不要漏了。3、然后按下回车确定,弹出对话框点击“确

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace("&nbsp;","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!