如何在 Windows 7 上安装 ImageMagick 以与 PHP 一起使用 (3)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20976779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install ImageMagick to use with PHP on Windows 7 (3)
提问by embe
There are other threads about how to install Imagick on Windows 7 but no help for me so far. :(
还有其他关于如何在 Windows 7 上安装 Imagick 的线程,但到目前为止对我没有帮助。:(
(Maybe problems have came up with more recent versions)
(也许最近的版本出现了问题)
I have followed these steps to install:
我已按照以下步骤进行安装:
Download and install ImageMagick
http://www.imagemagick.org/download/binaries/ImageMagick-6.8.8-1-Q16-x86-dll.exe
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
Edit php.ini file and add new extension (c:\xampp\php\php.ini)
extension=php_imagick.dll
Save ini file and restart Apache (if necessary, restart Windows)
Start Apache and run test
下载并安装 ImageMagick
http://www.imagemagick.org/download/binaries/ImageMagick-6.8.8-1-Q16-x86-dll.exe
下载 php_imagick.dll 并复制到扩展目录 (c:\xampp\php\ext)
http://www.peewit.fr/imagick/php55/vc11/x86/ts/php_imagick.dll
编辑 php.ini 文件并添加新的扩展名 (c:\xampp\php\php.ini)
扩展名=php_imagick.dll
保存 ini 文件并重新启动 Apache(如有必要,请重新启动 Windows)
启动Apache并运行测试
When I start Apache i get a pop up box that displays:
当我启动 Apache 时,我得到一个弹出框,显示:
The program can't start because php5.dll is missing from your computer. Try reinstalling the program to fix this problem.
程序无法启动,因为您的计算机缺少 php5.dll。尝试重新安装程序以解决此问题。
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.
PHP 启动:无法加载动态库 'C:\xampp\php\ext\php_imagick.dll' - 找不到指定的模块。
According to funtioneerI suspect some kind of compilation error.
根据 funtioneer 的说法,我怀疑存在某种编译错误。
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.
现在我有 PHP 版本 5.5.6(xampp 1.8.3),编译器 MSVC11 与 php_imagick.dll 文件相同。
Is download ImageMagick from source and compile it on my own the right way to go? (have never compiled in Windows before)
从源代码下载 ImageMagick 并自行编译是正确的方法吗?(以前从未在 Windows 中编译过)
回答by embe
Instead of using the latest version I tried downloading ImageMagick-6.7.7-5-Q16-windows-dll from here. That one actually worked with the php_imagick.dll (Imagick for PHP 5.5.x) from http://www.peewit.fr/imagick/.
我没有使用最新版本,而是尝试从这里下载 ImageMagick-6.7.7-5-Q16-windows-dll 。那个实际上与来自http://www.peewit.fr/imagick/的 php_imagick.dll (Imagick for PHP 5.5.x) 一起工作。
This is not the latest version but it worked. (even without restarting the computer)
这不是最新版本,但它有效。(即使没有重新启动计算机)
回答by lithiumlab
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
Downloadand install ImageMagick
下载并安装 ImageMagick
ImageMagick-6.8.9-1-Q16-x86-dll.exe
Downloadcorresponding .zip from Anatol suggested sources (kudos to Anatol!)
从 Anatol 建议的来源下载相应的 .zip(感谢 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.
解压到一个临时文件夹并复制 Imagemagick 安装(c:\imagemagick)中“bin”文件夹的内容,在我的情况下覆盖文件。
Download .dlland put it in the php extensions folder
(I used this one)
下载后.dll放到php extensions文件夹(我用过这个)
Imagick for PHP 5.5.x Non Thread Safe from: http://www.peewit.fr/imagick/
Imagick for PHP 5.5.x 非线程安全来自:http://www.peewit.fr/imagick/
Add the extension to php.ini with:
使用以下命令将扩展添加到 php.ini:
extension=php_imagick.dll
Save php.ini and restart IIS
保存 php.ini 并重启 IIS
Finally Image Magick information was displayed in a phpinfo(); call.
最后在 phpinfo() 中显示了 Image Magick 信息;称呼。
It is incredible to think to solve this problem needed to download files from 3 different locations.
想到要解决从 3 个不同位置下载文件所需的这个问题,真是令人难以置信。
Hope it helps.
希望能帮助到你。
回答by Kris
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
这是我为使其工作所做的工作注意:真正让我感到困惑但并没有真正解释的步骤是 php_imagick.dll 版本应该与您安装的 imagick 相匹配
Ok so steps I taken was download php imagick dll from http://windows.php.net/downloads/pecl/releases/imagick/3.1.2/(I used php_imagick-3.1.2-5.5-ts-vc11-x86.zip)
好的,我采取的步骤是从http://windows.php.net/downloads/pecl/releases/imagick/3.1.2/下载 php imagick dll (我使用了 php_imagick-3.1.2-5.5-ts-vc11-x86。压缩)
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
zip 文件将包含许多 dll,请记住这一点,我们将来可能需要它。将 php_imagick.dll 解压到您的扩展文件夹
Put that in extension folder
把它放在扩展文件夹中
IN php.ini add extension = php_imagick.dll
在 php.ini 添加扩展名 = 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.
现在的问题是我们需要找出 php_imagick.dll 是为 Open 命令提示符编译的 imagick 版本,然后输入 php -e -v 我这样做的方法是使用您之前下载的 zip,将其他 DLL 解压缩到您的php 文件夹中可能会弹出一条错误消息,说明有关缺少 dll 的信息。因此,将之前 zip 文件夹中的 DLL 提取到您的 PHP 文件夹中。再次尝试运行 php -e -v ,它应该可以正常工作,没有错误消息。如果是这种情况,则重新启动 apache。现在查看 phpinfo() 并转到 imagick 部分。它会说 ImageMagick 版本:我说 ImageMagick 6.8.6-8 这是他们网站上的旧版本。问题是 ImageMagick 支持格式的数量:可能会说为零。
Go hereand 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.
安装完成后停止 apache。从之前放入的 php 文件夹中删除 DLLS,然后再次启动 apache。检查重新启动apache,它应该一切正常。
回答by Anatol Belski
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.
应该使用的 ImageMagic 发行版来自http://windows.php.net/downloads/pecl/deps/。ImageMagic 二进制文件需要使用与 PHP 扩展相同的 CRT 构建。
回答by mdo123
Please see installing-imagick-php-7for 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.
请参阅安装 imagick-php-7以使用 php 7.0 + 在 Windows 上安装 imagick php 扩展。到目前为止,这只是我找到的真正解决方案。它非常详细。
回答by Alexufo
UPDATED: 21.08.2017
更新:21.08.2017
I got worked ImageMagick with php 7 and IIS (Apache very similar): Imagick Version. 3.4.3
我使用 php 7 和 IIS(Apache 非常相似)使用 ImageMagick:Imagick版本。3.4.3
PHP 7 nts x86, Windows Server 2012 x64, IIS 8.5
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
1) 安装 VC++ 2015 https://www.microsoft.com/en-US/download/details.aspx?id=48145
2) Get ONLYphp_imagick.dllfrom https://pecl.php.net/package/imagick
2)获取ONLYphp_imagick.dll从https://pecl.php.net/package/imagick
3) Put it into php/ext/ folder and add extension=php_imagick.dllto php.ini
3) 放入 php/ext/ 文件夹并添加extension=php_imagick.dll到php.ini
Attention!Minimum versions supported PHP >= 5.4.0 and ImageMagick >= 6.5.3-10.
注意力!最低版本支持 PHP >= 5.4.0 和 ImageMagick >= 6.5.3-10。
ImageMagick 7 are not supported at this time.
目前不支持 ImageMagick 7。
Look at phpinfo:
查看phpinfo:
You must install ImageMagick 6.9.3-7 Q16 x86
4) install ImageMagick 6.9.3-7 Q16 x86 dllfrom http://ftp.icm.edu.pl/packages/ImageMagick/binaries/Do not uncheck "add variable to path".
您必须安装 ImageMagick 6.9.3-7 Q16 x86 4)ImageMagick 6.9.3-7 Q16 x86 dll从http://ftp.icm.edu.pl/packages/ImageMagick/binaries/安装
不要取消选中“将变量添加到路径”。
5) restart server
5)重启服务器
thats all
就这样
回答by FavorMylikes
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
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.dllversion from
http://windows.php.net/downloads/pecl/releases/imagick/
php_imagick.dll从http://windows.php.net/downloads/pecl/releases/imagick/选择一个版本
Find php_imagick.dllfrom .zipfile
php_imagick.dll从.zip文件中查找
If you don't know how to choose.
如果你不知道如何选择。
Type php -vget php version at commandline window
类型php -v让PHP版本,在命令行窗口
Run following code shows which kind of php you have installed,thread safeor non thread safe.and click herewill help you.
运行以下代码显示您安装了哪种类型的 php,thread safe或者non thread safe单击此处可以帮助您。
On windows:php -i|find "Thread"
在窗户上:php -i|find "Thread"
On Linux:php -i|grep Thread
在 Linux 上:php -i|grep Thread
or you can run function phpinfo()and search "Thread"on web page.
或者您可以在网页上运行功能phpinfo()和搜索"Thread"。
You will see Thread Safety enabledor Thread Safety disabled
你会看到Thread Safety enabled或Thread Safety disabled
Other steps have already been written out by @embe.
@embe 已经写出了其他步骤。
回答by ashkufaraz
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.
现在对于文档没有提到的内容:在您的环境中设置 MAGICK_HOME 值。ImageMagick 需要这个变量,所以它知道在哪里可以找到所有相关的编码器。
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.
打开控制面板,然后搜索“PATH”。在结果中,选择“编辑系统环境变量”。选择“环境变量...”选项,然后添加一个新的“系统变量”(下方列表)。如果您选择了不同的安装路径,请确保将 C:\img 替换为您自己的路径。
Variable: MAGICK_HOME
变量:MAGICK_HOME
Value: C:\img\modules\coders
值:C:\img\modules\coders
回答by Kim Steinhaug
Solved!
解决了!
After having the same problems and some googling I found the solution for windows, and it seems to work for every release as well.
在遇到同样的问题和一些谷歌搜索之后,我找到了 Windows 的解决方案,它似乎也适用于每个版本。
In my case PHP is installed at c:\php and my extension dir is at c:\php\ext.
在我的情况下,PHP 安装在 c:\php,我的扩展目录在 c:\php\ext。
- Copy "php_imagick*" into c:\php\ext
- Copy "CORE_RL_*", "FILTER_*", "IM_MOD_*" into c:\php
- Add "extension=imagick" to php.ini
- 将“php_imagick*”复制到c:\php\ext
- 将“CORE_RL_*”、“FILTER_*”、“IM_MOD_*”复制到c:\php
- 将“extension=imagick”添加到 php.ini
Restart apache and your done.
重启 apache 就完成了。


