简体   繁体   English

如何在 Windows 7 上安装 ImageMagick 以与 PHP 一起使用 (3)

[英]How to install ImageMagick to use with PHP on Windows 7 (3)

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:我已按照以下步骤进行安装:

  1. Download and install ImageMagick下载并安装 ImageMagick

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

  1. Download php_imagick.dll and copy to extension dir (c:\\xampp\\php\\ext)下载 php_imagick.dll 并复制到扩展目录 (c:\\xampp\\php\\ext)

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

  1. Edit php.ini file and add new extension (c:\\xampp\\php\\php.ini)编辑 php.ini 文件并添加新的扩展名 (c:\\xampp\\php\\php.ini)

extension=php_imagick.dll扩展名=php_imagick.dll

  1. Save ini file and restart Apache (if necessary, restart Windows)保存 ini 文件并重新启动 Apache(如有必要,请重新启动 Windows)

  2. Start Apache and run test启动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.程序无法启动,因为您的计算机缺少 php5.dll。 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. PHP 启动:无法加载动态库 'C:\\xampp\\php\\ext\\php_imagick.dll' - 找不到指定的模块。

According to funtioneer I suspect some kind of compilation error. 根据 funtioneer 的说法,我怀疑存在某种编译错误。

Now I have PHP Version 5.5.6 (xampp 1.8.3) with compiler MSVC11 which 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?从源代码下载 ImageMagick 并自行编译是正确的方法吗? (have never compiled in Windows before) (以前从未在 Windows 中编译过)

Instead of using the latest version I tried downloading ImageMagick-6.7.7-5-Q16-windows-dll from here .我没有使用最新版本,而是尝试从这里下载 ImageMagick-6.7.7-5-Q16-windows-dll。 That one actually worked with the php_imagick.dll (Imagick for PHP 5.5.x) from http://www.peewit.fr/imagick/ .那个实际上与来自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) (即使没有重新启动计算机)

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

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

Download corresponding .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 .dll and 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();最后在 phpinfo() 中显示了 Image Magick 信息; call.称呼。

It is incredible to think to solve this problem needed to download files from 3 different locations.想到要解决从 3 个不同位置下载文件所需的这个问题,真是令人难以置信。

Hope it helps.希望能帮助到你。

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. zip 文件将包含许多 dll,请记住这一点,我们将来可能需要它。 Extract php_imagick.dll to your extension folder将 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.现在的问题是我们需要找出 php_imagick.dll 是为 Open 命令提示符编译的 imagick 版本,然后输入 php -e -v 我这样做的方法是使用您之前下载的 zip,将其他 DLL 解压缩到您的php 文件夹中可能会弹出一条错误消息,说明有关缺少 dll 的信息。 So extract the DLLs from the zip folder from before into your PHP folder.因此,将之前 zip 文件夹中的 DLL 提取到您的 PHP 文件夹中。 Try running php -e -v again and it should work fine with no error message.再次尝试运行 php -e -v ,它应该可以正常工作,没有错误消息。 If that is the case then Restart apache.如果是这种情况,则重新启动 apache。 Now look at phpinfo() and go to the imagick section.现在查看 phpinfo() 并转到 imagick 部分。 It will say ImageMagick version: Mine said ImageMagick 6.8.6-8 which is an older version then they have on their site.它会说 ImageMagick 版本:我说 ImageMagick 6.8.6-8 这是他们网站上的旧版本。 The issue is that ImageMagick number of supported formats: will probably say zero.问题是 ImageMagick 支持格式的数量:可能会说为零。

Go here 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.安装完成后停止 apache。 Delete the DLLS from the php folder that you put in earlier and start apache again.从之前放入的 php 文件夹中删除 DLLS,然后再次启动 apache。 Check restart apache and it should all work.检查重新启动apache,它应该一切正常。

The ImageMagic distribution which should be used is from here http://windows.php.net/downloads/pecl/deps/ .应该使用的 ImageMagic 发行版来自http://windows.php.net/downloads/pecl/deps/ The ImageMagic binaries need to be built with the same CRT as the PHP extension is. ImageMagic 二进制文件需要使用与 PHP 扩展相同的 CRT 构建。

Please see installing-imagick-php-7 for installing imagick php extension on Windows using php 7.0 +.请参阅安装 imagick-php-7以使用 php 7.0 + 在 Windows 上安装 imagick php 扩展。 It's only real solution I have found so far.到目前为止,这只是我找到的真正解决方案。 It goes into great detail.它非常详细。

UPDATED: 21.08.2017更新:21.08.2017

I got worked ImageMagick with php 7 and IIS (Apache very similar): Imagick Version.我使用 php 7 和 IIS(Apache 非常相似)使用 ImageMagick:Imagick版本。 3.4.3 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 ONLY php_imagick.dll from https://pecl.php.net/package/imagick 2)得到php_imagick.dllhttps://pecl.php.net/package/imagick

3) Put it into php/ext/ folder and add extension=php_imagick.dll to 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 dll from http://ftp.icm.edu.pl/packages/ImageMagick/binaries/ Do not uncheck "add variable to path".您必须安装 ImageMagick 6.9.3-7 Q16 x86 4) 从http://ftp.icm.edu.pl/packages/ImageMagick/binaries/安装ImageMagick 6.9.3-7 Q16 x86 dll不要取消选中“将变量添加到路径”。

5) restart server 5)重启服务器

thats all就这样

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.dll version from http://windows.php.net/downloads/pecl/releases/imagick/http://windows.php.net/downloads/pecl/releases/imagick/选择一个php_imagick.dll版本

Find php_imagick.dll from .zip file.zip文件中找到php_imagick.dll

If you don't know how to choose.如果你不知道如何选择。

Type php -v get php version at commandline window在命令行窗口输入php -v获取 php 版本

Run following code shows which kind of php you have installed, thread safe or non thread safe .and click here will help you.运行以下代码显示您安装了哪种类型的 php, thread safe non thread safe单击此处将为您提供帮助。

On windows: php -i|find "Thread"在 Windows 上: 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 enabled or Thread Safety disabled您将看到Thread Safety enabled Thread Safety disabledThread Safety disabled

Other steps have already been written out by @embe. @embe 已经写出了其他步骤。

Now for something the documentation does not mention: setting the MAGICK_HOME value in your environment.现在对于文档没有提到的内容:在您的环境中设置 MAGICK_HOME 值。 ImageMagick requires this variable so it knows where to find all relevant coders. ImageMagick 需要这个变量,所以它知道在哪里可以找到所有相关的编码器。

Open up the control pannel, and search for 'PATH'.打开控制面板,然后搜索“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.如果您选择了不同的安装路径,请确保将 C:\\img 替换为您自己的路径。

Variable: MAGICK_HOME变量:MAGICK_HOME

Value: C:\\img\\modules\\coders值:C:\\img\\modules\\coders

see more 查看更多

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。

  1. Copy "php_imagick*" into c:\\php\\ext将“php_imagick*”复制到c:\\php\\ext
  2. Copy "CORE_RL_*", "FILTER_*", "IM_MOD_*" into c:\\php将“CORE_RL_*”、“FILTER_*”、“IM_MOD_*”复制到c:\\php
  3. Add "extension=imagick" to php.ini将“extension=imagick”添加到 php.ini

Restart apache and your done.重启 apache 就完成了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM