【巨坑--问你怕不怕】--windows下面配置imagick的相关资料。

最近的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测试代码。

<?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' );
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

10. 查看手册,学习API

相关扩展学习手册地址 http://uk3.php.net/manual/zh/book.imagick.php 手册中包含大量易用实例。 
这里还有查看命令行参数的文档 http://www.imagemagick.org/Usage/



DLL在这里下载:

点击打开链接



There are other threads about how to install Imagick on Windows 7 but no help for me so far. :(

(Maybe problems have came up with more recent versions)

I have followed these steps to install:

  1. Download and install ImageMagick

    http://www.imagemagick.org/download/binaries/ImageMagick-6.8.8-1-Q16-x86-dll.exe

  2. Download php_imagick.dll and copy to extension dir (c:\xampp\php\ext)

    http://www.peewit.fr/imagick/php55/vc11/x86/ts/php_imagick.dll

  3. Edit php.ini file and add new extension (c:\xampp\php\php.ini)

    extension=php_imagick.dll

  4. Save ini file and restart Apache (if necessary, restart Windows)

  5. Start Apache and run test

When I start Apache i get a pop up box that displays:

The program can't start because php5.dll is missing from your computer. Try reinstalling the program to fix this problem.

Then directly after this comes another:

PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_imagick.dll' - The specified module could not be found.

According to funtioneer I suspect some kind of compilation error.

Now I have PHP Version 5.5.6 (xampp 1.8.3) with compiler MSVC11 wich is the same as for the php_imagick.dll file.

Is download ImageMagick from source and compile it on my own the right way to go? (have never compiled in Windows before)

share improve this question
 

8 Answers

up vote 23 down vote accepted

Instead of using the latest version I tried downloading ImageMagick-6.7.7-5-Q16-windows-dll from http://ftp.sunet.se/pub/multimedia/graphics/ImageMagick/binaries/. That one actually worked with the php_imagick.dll (Imagick for PHP 5.5.x) from http://www.peewit.fr/imagick/.

This is not the latest version but it worked. (even without restarting the computer)

share improve this answer
 
2 
Thanks for the link to the older versions and the advice to downgrade. This was an absolute crapshoot for me. Just in case anyone else is trying to do this, I was able to get everything working using the ImageMagick-6.7.0-10-Q16-windows-dll.exe from the ftp.sunset.se link. I'm using Apache and PHP 5.3.x on Windows 7. No Windows restart required, but I did restart Apache –  Funktr0n  Feb 13 '14 at 11:11 
2 
I can confirm that this works for Windows 8 x64 too... –  bScutt  Apr 2 '14 at 10:35
1 
It works :) PHP 5.5, Windows 7 –  czjvic  May 13 '14 at 6:17
 
It works. I downloaded the imagick dll from peewit.fr/imagick and kept a note of the ImageMagick version with which it was tested. Then I downloaded the particular version from ftp.sunet.se/pub/multimedia/graphics/ImageMagick/binaries –  jim_kastrin  Aug 14 '14 at 8:41
1 
God bless you @embe!!! I lost the better part of the day trying to setup imagick on my Windows 7 machine. The current version now is 6.9.0-8, along with imagick 3.1.2, php 5.5/5.6. I tried dozens of tuts but your is finally working for me! –  Stan  Feb 25 '15 at 19:42

Here what finally worked for me after trying almost every possible solution posted in internet:

Environment:

OS: Windows Server 2008 R2 (64bit)

IIS: 7.5

PHP: 5.5.11 (x86)

PHP.ini: VC11, x86

Download and install ImageMagick

ImageMagick-6.8.9-1-Q16-x86-dll.exe

Download corresponding .zip from Anatol suggested sources (kudos to Anatol!)

ImageMagick-6.8.9-1-vc11-x86:

Extract to a temporary folder and copy the contents of the "bin" folder inside the Imagemagick installation (c:\imagemagick) in my case overwriting files.

Download .dll and put it in the php extensions folder (I used this one)

Imagick for PHP 5.5.x Non Thread Safe from: http://www.peewit.fr/imagick/

Add the extension to php.ini with:

extension=php_imagick.dll

Save php.ini and restart IIS

Finally Image Magick information was displayed in a phpinfo(); call.

It is incredible to think to solve this problem needed to download files from 3 different locations.

Hope it helps.

share improve this answer
 
 
worked perfectly for me: OS: Windows 8.1 (64bit) PHP: 5.5.11 I downloaded ImageMagick-6.8.9-1-Q16-x86-dll.exe from sunet.se because the latest stable version of ImageMagick 6.8.9.6. showed this error –  con  Jul 30 '14 at 21:08
 
where did you get the .dll file from? thanks –  davey  Feb 24 '15 at 14:25
1 
 
Cheers thanks for that –  davey  Feb 25 '15 at 8:36
1 
As the question was about XAMPP which of course is Apache and not IIS maybe you should amend that piece of your answer. –  RiggsFolly  Jan 12 at 11:50 

Here is what I did to get it working Note: The step that really tripped me up that didn't really explain is that the php_imagick.dll version should match your install of imagick

Ok so steps I taken was download php imagick dll fromhttp://windows.php.net/downloads/pecl/releases/imagick/3.1.2/ (I used php_imagick-3.1.2-5.5-ts-vc11-x86.zip)

The zip file will contain many dlls keep this in mind, we may need it in future. Extract php_imagick.dll to your extension folder

Put that in extension folder

IN php.ini add extension = php_imagick.dll

Now the issue is we need to find out what version of imagick the php_imagick.dll was compiled for Open command prompt and type in php -e -v The way I did this was with the zip you downloaded earlier, extract the other DLLs to your php folder an error message will probably popup stating something about missing dlls. So extract the DLLs from the zip folder from before into your PHP folder. Try running php -e -v again and it should work fine with no error message. If that is the case then Restart apache. Now look at phpinfo() and go to the imagick section. It will say ImageMagick version: Mine said ImageMagick 6.8.6-8 which is an older version then they have on their site. The issue is that ImageMagick number of supported formats: will probably say zero.

Go to http://ftp.sunet.se/pub/multimedia/graphics/ImageMagick/binaries/ ANd download the matching version and install (when you install make sure the checkbox of adding to path variable is checked)

Once finish installing Stop apache. Delete the DLLS from the php folder that you put in earlier and start apache again. Check restart apache and it should all work.

share improve this answer
 
 
I've tried to get this working for a long time. The crucial part for me was copying the additional DLL files into the php folder! –  AJReading  Jul 31 '14 at 14:05

The ImageMagic distribution which should be used is from here http://windows.php.net/downloads/pecl/deps/ . The ImageMagic binaries need to be built with the same CRT as the PHP extension is.

share improve this answer
 

I get working ImageMagick with php 7 and IIS (Apache very similar):

PHP 7 nts x86, Windows Server 2012 x64, IIS 8.5

1) Install VC++ 2015 https://www.microsoft.com/en-US/download/details.aspx?id=48145

2) Get ONLY php_imagick.dll from https://pecl.php.net/package/imagick

3) Put it into php/ext/ folder and add extension=php_imagick.dll to php.ini

4) install ImageMagick-6.9.3-0-Q16-x86-dll.exe from http://imagemagick.org/script/binary-releases.php Do not uncheck "add variable to path".

5) restart server

thats all

share improve this answer
 
 
You do not need the whole VC++ 2013, All you need is the runtime libraries from here You also need to add this extension=php_imagick.dll to your php.ini file. A reboot is not necessary, all you need to do is restart Apache. –  RiggsFolly  Jan 12 at 11:46 
 
Yes i mean only libraries and provide link for it. And i use IIS8. –  Alexufo  Jan 12 at 17:50 
 
But the person asking the question uses XAMPP which means they use Apache. –  RiggsFolly  Jan 13 at 9:52

It works by following steps.

php 5.5 32bit ts+apache 2.4+windows 10 64bit+Imagick 6.9.3-5+php_imagick.dll ts

Check what's bit of your system bit.

Choose a php_imagick.dll version from http://windows.php.net/downloads/pecl/releases/imagick/

Find php_imagick.dll from .zip file

If you don't know how to choose.

Type php -v get php version at commandline window

Run following code shows which kind of php you have installed,thread safe or non thread safe.and click here will help you.

On windows:php -i|find "Thread"

On Linux:php -i|grep Thread

or you can run function phpinfo() and search "Thread" on web page.

You will see Thread Safety enabled or Thread Safety disabled

Other steps have already been written out by @embe.

share improve this answer
 

Now for something the documentation does not mention: setting the MAGICK_HOME value in your environment. ImageMagick requires this variable so it knows where to find all relevant coders.

Open up the control pannel, and search for 'PATH'. In the results, select 'Edit the system environment variables'. Select the 'Environment variables...' option, and add a new 'System variable' (the lower list). If you've chosen a different installation path, make sure to replace C:\img with your own path.

Variable: MAGICK_HOME

Value: C:\img\modules\coders

see more

share improve this answer
 

Please see installing-imagick-php-7 for installing imagick php extension on Windows using php 7.0 +. It's only real solution I have found so far. It goes into great detail.

share improve this answer
 

protected by Community Apr 17 at 19:22

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count). 

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged      or ask your own question.



 

windows7下   php5.4成功安装imageMagick 。    

(phpinfo中显示不出来是因为:1.软件本身、php本身、php扩展三方版本要一致,2.需要把CORE_RL_*.dll多个文件放到/php/目录下面)

                                                                                                     (作者:王奇疏 http://www.cnblogs.com/wangqishu/p/5609950.html )

 
楼主需要用php处理一些特别的图片事宜,所以安装了iMagick for php来编写程序。

 

先看一下,这是我在windwos7安装成功的 imageMagick for php 的phpinfo()截图

 

   和调用imagick插件 的 php程序执行成功 截图

 

安装步骤:

1). 先确定你使用的php版本情况,比如王奇疏的pc是win7的php : php5.4  x86 ts

    那么就需要三方版本 要一致:imagick软件本身( 如x86 )、php本身( x86 ts (thread safe) )、php扩展php_imagick.dll ts) 。

 

2).在已经安装了php的情况下,需要下载2个软件: imagick软件本身、php扩展php_imagick.dll扩展包:
   

    
    imagick软件本身:  http://imagemagick.org/script/binary-releases.php#windows

                                   


           
 楼主选择的是:ImageMagick-6.8.9-6-Q16-x86-dll.exe 百度盘下载   运行安装即可

    因为最新版本的 php_imagick.dll (最新版本3.4.2  2016.06.22)
    只支持到  ImageMagick 6.8.9   (2014-05-08)
    所以,楼主已更换为  ImageMagick 6.8.9-1 Q16 x86.exe  楼主提供了1个百度盘下载地址,x64或其它版本请自行搜索摸索。 
    (by 王奇疏) 。

    这是exe二进制安装包,如果你是x64位的请自行搜索这个版本的下载,或者你换了别的版本的请自行摸索测试。 如果你下载的是stable便携包相当于绿色版,那么需要自己把  文件路径  放到系统的环境变量。

) 

    php扩展php_imagick.dll扩展包http://pecl.php.net/package/imagick/

            楼主选择的是:http://pecl.php.net/package/imagick/3.4.2/windows  

             PHP 5.4 :5.4 Thread Safe (TS) x86

 

3).安装软件和配置

    安装imagick软件本身,一直下一步即可;

    安装php扩展插件:php_imagick.dll  ,同其他php dll插件一样。 
     ①.从php扩展压缩包中将php_imagick.dll 拖到/php/ext
 目录下,

     ②.在php.ini开启插件 extension=php_imagick.dll ,

     ③. 从扩展压缩包中将多个  CORE_RL_*.dll 文件拖到 /php/ 目录下(否则重启apache或者 命令行 php -ri imagick 调试时报错找不到*.dll )

                        

 

4. 重启Apache,查看 phpinfo() 中是否有 Imagick 项,如果有说明安装成功。

 

5.  需要另外 新建一个系统环境变量名为MAGICK_HOME,值为E:\你的imagick路径\modules\coders, 这步主要用来定位imagemagickmodule,很重要。( 否则支持的图片格式数量默认为0, 无法处理图片。 ImageMagick number of supported formats:  => 0 )

 

如果没有Imagick 项,请 使用 php扩展调试命令  来检查扩展中存在的问题, 并确保三方软件版本一致即可。

php扩展  调试命令:

在cmd运行:  php --ri imagick

 

1. 如果报错是:“php_imagick.dll' - %1 不是有效的 Win32 应用程序” ,则说明版本不相符合。 需要检查   imagick软件本身( 如x86 )、php本身( x86 ts (thread safe) )、php扩展php_imagick.dll (ts) 三方版本 要一致。

 

2. 如果报错是:“php.exe - 系统错误 ,无法启动此程序因为计算机丢失CORE_RL_wand_.dll ” , 说明你没有将 php_imagick-3.3.0-5.4-ts-vc9-x86.zip 扩展包中的“CORE_*.dll” 这些dll文件 放到 你的php.exe同级目录下。   ,只需要拷贝 CORE_*.dll 到php目录就可以解决了。

 

3. 如果php --ri imagick 显示的结果  ImageMagick number of supported formats:  => 0 支持的图片格式数量为0,请看第5步需要新建一个环境变量。

4.如果php代码执行调用时报错:“ NoDecodeDelegateForThisImageFormat ”,表明你的php_imagick.dll的版本 并不支持或并不匹配 ImageMagick软件版本,这时候 php --ri imagick 的结果也显示为: ImageMagick number of supported formats => 0 。需要更换ImageMagick软件版本。 






最近在windows2003和iis6下面安装PHP的imagick扩展,耗费了很多时间,看见了很多资料,有些竟然是错的。现在把常用的文件列出来,有需要的朋友可以下载一下,当然也方便我下一次安装和调试,这里没有提供适合apache的文件,大家可以去对应网站找找:


1、PHP5.2.17我安装成功了,用的星外PHP5.2.17直接安装程序,下载imagick版本如下:

http://valokuva.org/outside-blog-content/imagick-windows-builds/080709/php_imagick_st-Q16.dll
(备份下载http://www.zzzyk.com/upload/20121109/php_imagick_st-Q16.dll)


已经包含imagemagick不需要安装任何东西,直接把php_imagick_st-Q16.dll复制到c:\php\ext目录
然后给php.ini扩展里面增加:extension=php_imagick_st-Q16.dll 最简单和绿色的方法
ps:还有诸如php_imagick_st-Q8.dll(8色),php_imagick_dyn-Q16.dll(需要安装imagemagick)就完全没必要管他们了


PHP5.2.17官方对应http://windows.php.NET/downloads/releases/php-5.2.17-nts-Win32-VC6-x86.zip
推荐下载星外版本http://www.zzzyk.com/upload/20121109/php5.2.17.rar安装很简单,基本上装了就可以使用php


2、PHP5.3.18 必须安装 imagemagick 已经没有可用的单文件dll了


1)下载 http://www.imagemagick.org/download/binaries/ImageMagick-6.8.0-4-Q16-windows-dll.exe
2)根据你的php安装模式下载 php_imagick


无线程安全:http://valokuva.org/builds/ext/vc9/nts/imagick/2011-04-25_1849/php_imagick_nts.dll 
(备份下载:http://www.zzzyk.com/upload/20121109/php_imagick_nts__PHP5318.dll)
(通常iis6下面fastcgi对应http://windows.php.Net/downloads/releases/php-5.3.18-nts-Win32-VC9-x86.zip)
线程安全:http://valokuva.org/builds/ext/vc9/ts/imagick/2011-04-25_1849/php_imagick_ts.dll 
(备份下载:http://www.zzzyk.com/upload/20121109/php_imagick_ts__PHP5318.dll)
(我已经没用isapi的php对应http://windows.php.net/downloads/releases/php-5.3.18-Win32-VC9-x86.zip)


复制到c:\php\ext目录,增加扩展例如:extension=php_imagick_nts.dll


3、PHP5.4.8  必须安装 imagemagick 已经没有可用的单文件dll了


1)下载 http://www.imagemagick.org/download/binaries/ImageMagick-6.8.0-4-Q16-windows-dll.exe
2)根据你的PHP安装模式下载 php_imagick
无线程安全:http://www.peewit.fr/imagick/vc9/x86/nts/php_imagick.dll
(备份下载:http://www.zzzyk.com/upload/20121109/php_imagick_nts.dll)
(对应http://windows.php.net/downloads/releases/php-5.4.8-nts-Win32-VC9-x86.zip)
线程安全:http://www.peewit.fr/imagick/vc9/x86/ts/php_imagick.dll
(备份下载:http://www.zzzyk.com/upload/20121109/php_imagick_ts.dll)
(对应http://windows.php.net/downloads/releases/php-5.4.8-Win32-VC9-x86.zip)


复制到c:\php\ext目录,增加扩展例如:extension=php_imagick.dll

以上安装本人都测试过,安装了重启iis,然后查看phpinfo看看有没有 imagick 如果没有的话,请检查权限或者重新做一次。也欢迎那些喜欢调试vc的朋友,把最新版本的imagemagick调成适合windows2003+iis平台使用的dll.




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值