转自

http://herbmiller.me/2016/06/16/installing-imagick-php-7/

If you’re running PHP 7 on Windows and you want to use the Imagick PHP extension then you may want to refer to this post for some download and installation instructions.

Background

I recently spent far too long trying to convince incompatible binaries that they should work together. All I wanted to do was to write some code that would automatically correct the orientation of an uploaded image, based on the value of the Orientation field in the image’s EXIF data. And, in order to test it, I needed a method of setting the orientation.

To do that I needed to install the Imagick PHP Extension. I thought that the installation would be doddle. It wasn’t.

I chased a lot of wild geese and followed many red herrings until I eventually found the correct hint for the location of the ImageMagick binary files upon which the Imagick PHP extension is dependent.

I hope that you’ll find these notes to be useful.

Overview

Imagick is a native PHP extension to create and modify images using the ImageMagick API.

It provides a DLL that you need to install as an extension to your PHP installation.

The DLL is dependent on functionality provided by ImageMagick.

You need to use compatible versions. i.e. The version used to build the library should match the run time version.

If you don’t then it won’t work.

Finding the correct files to download was probably the hardest part of the installation.

The second hardest part was undoing all the failed attempts to configure incompatible versions.

Then there was making sure these instructions actually worked.

Installation

Determine your version of PHP, whether or not it’s Thread Safe, and the architecture.

Download the Imagick extension you need.

Change php.ini to enable the php_imagick extension.

Extract the .dll files from the Imagick extension zip file.

Download the compatible version of ImageMagick.

Install ImageMagick to a directory of your choice.

Set the environment to enable the ImageMagick DLLs to be found.

Reboot.

Test.

Determine your version of PHP

Use php -i to run phpinfo() and look at the first few lines of the output

PHP Version => 7.0.7

System => Windows NT QW 10.0 build 10586 (Windows 10) AMD64

Build Date => May 25 2016 12:48:08

Compiler => MSVC14 (Visual C++ 2015)

Architecture => x64

...

Loaded Configuration File => C:\php7\php.ini

...

Thread Safety => enabled

...

Download the Imagick extension you need

Download a version compatible with your version of PHP.  e.g. php_imagick-3.4.3rc1-7.0-ts-vc14-x64.zip

Change php.ini to enable the php_imagick extension

Determine the directory for extensions by checking for the extension_dir directive in your phpinfo output.

Directive => Local Value => Master Value

extension_dir => C:\php7\ext => C:\php\ext

If the top level directory doesn’t match that from which PHP is run then you should either correct the local value or fully qualify the file name of the extension.

extension=c:/php7/ext/php_imagick.dll

Or do both.

Extract the .dlls from the Imagick extension .zip file

Since PHP extensions are loaded dynamically, you need to tell PHP where to find them. It doesn’t use the PATH for this. You either need to fully qualify the file name or define the extension_dir directive.

For php_imagick.dll to be loadable all the DLLs upon which it is statically dependent also need to be accessible.

When ImageMagick is installed then you will be using its DLLs. In the mean time you need to extract all of them, ensuring that they are in a directory that’s in your PATH.

You have two options. Copy the files into a directory that’s already in your PATH, or add the directory to your PATH.

I chose to install all the .dll files ( php_imagick.dll and 7 starting CORE_ ) into c:\php7\ext and added that directory to my PATH, after the entry for C:\php7.

Download the compatible version of ImageMagick

With the extension installed it is now possible to determine the version of ImageMagick upon which php_imagick.dll is dependent.

Run php -i and check the output.

imagick

imagick module => enabled

imagick module version => 3.4.3RC1

imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel

Imagick compiled with ImageMagick version => ImageMagick 6.9.3-7 Q16 x64 2016-03-27 http://www.imagemagick.org

Imagick using ImageMagick library version => ImageMagick 6.9.3-7 Q16 x64 2016-03-27 http://www.imagemagick.org

ImageMagick copyright => Copyright (C) 1999-2015 ImageMagick Studio LLC

ImageMagick release date => 2016-03-27

The version of ImageMagick you will need is shown in “Imagick compiled with ImageMagick version”.

Now you won’t find what you’re looking for at www.imagemagick.org. You need to go to http://windows.php.net/downloads/pecl/deps

The file I downloaded was ImageMagick-6.9.3-7-vc14-x64.zip

Install ImageMagick to a directory of your choice

Extract the whole of the bin directory from the ImageMagick zip file to a directory of your choice. I chose C:\ImageMagick-6.9.3-7

Set the environment to enable the ImageMagick DLLs to be found

Use “Edit the system environment variables” to edit the System variables section.

From the command prompt run SystemPropertiesAdvanced.

Add an entry to the PATH for ImageMagick ensuring it is before the entry for the PHP extensions.

Add an entry for MAGICK_HOME setting it to the ImageMagick home directory.

Reboot

Rebooting is the simplest way of ensuring that your system notices the changes you have made.

If you’re just running PHP from the Command Prompt you should be able to get away with closing one and opening a new Command Prompt.

Or you may choose to use ApacheMonitor to stop and restart your web server. But this may not pick up system environment changes.

Test

Check your phpinfo() output shows a non-zero value for ImageMagick number of supported formats.  You should see something like this

ImageMagick number of supported formats: => 234

ImageMagick supported formats => a, long, list, of, formats, comma, space, separated, including, common, ones, such, as, JPG, PDF, PNG

Also test phpinfo from your browser. Expect the same result.

Try some code.

Basic problem determination

If you get the following when running php -i

Warning: PHP Startup: Unable to load dynamic library 'c:/php7/ext/php_imagick.dll' - The specified module could not be found.

in Unknown on line 0

then you will need to make sure the dependent DLLs are correctly installed.

In phpinfo output, if you do not have the correct version of ImageMagick installed and configured then you will probably see

ImageMagick number of supported formats: => 0

ImageMagick supported formats =>

If you try running PHP code that uses Imagick and you get CLI has stopped working, then you have incompatible versions. Check you don’t have another version of Imagick running.

I got this problem when I was running the latest version ( ImageMagick 7.0.2-0 ) from imagemagick.org.

It’s also possible that php -i produces the correct output but phpinfo on the browser shows 0 supported formats. Possible solutions:

I discovered that removing the additional DLLs extracted from the php_imagick zip file into the C:\php7\ext directory resolved this problem.

Changing the sequence of directories in the PATH also resolved it.

Ensuring MAGICK_HOME is correctly set in the System environment variables.

Summary of downloads

Note: I chose to update my version of PHP to 7.0.7

Component

URL

Version required

PHP 7

VC14 x64 Thread Safe (2016-May-25 23:02:16)

Imagick extension

php_imagick-3.4.3rc1-7.0-ts-vc14-x64.zip

ImageMagick runtime

ImageMagick-6.9.3-7-vc14-x64.zip

My local installation

Directory/File

Contains

C:\php7

PHP 7.0.7 thread safe X64

C:\php7\php.ini

PHP configuration file

C:\php7\ext

PHP extensions including php_imagick.dll

C:\ImageMagick-6.9.3.7

Extracted files from the ImageMagick .zip file’s bin directory

Environment variables

Variable

Purpose

Contents

PATH

System path

includes C:\ImageMagick-6.9.3-7 C:\php7 and C:\php7\ext in that order

MAGICK_HOME

ImageMagick home

C:\ImageMagick-6.9.3-7

References

imagick php7.0,Installing Imagick for PHP 7 on Windows 10相关推荐

  1. centos php7.0 mysql_CentOS 7.3 下 安装LNMP(Nginx1.10+MySQL5.7+PHP7.0.20)

    前言:最近总是要安装服务器环境,记录这次CentOS 7.3下安装LNMP(Nginx1.10+MySQL5.7+PHP7.0.20)环境的过程,以备日后使用. 一.准备工作 1. 更新源 # yum ...

  2. Free Download Manager FDM 6.13.0 官方版下载工具,适用 Windows 10/8.1/8/7 6.13

    Free Download Manager (FDM) 是一款经典免费纯粹的下载软件,它开源无广告,界面简洁清爽,支持计划任务.支持多线程下载.支持 BT下载.FTP下载,种子下载.磁力下载.P2P加 ...

  3. 背水一战 Windows 10 (83) - 用户和账号: 数据账号的添加和管理, OAuth 2.0 验证

    原文:背水一战 Windows 10 (83) - 用户和账号: 数据账号的添加和管理, OAuth 2.0 验证 [源码下载] 背水一战 Windows 10 (83) - 用户和账号: 数据账号的 ...

  4. 背水一战 Windows 10 (1) - C# 6.0 新特性

    背水一战 Windows 10 (1) - C# 6.0 新特性 原文:背水一战 Windows 10 (1) - C# 6.0 新特性 [源码下载] 背水一战 Windows 10 (1) - C# ...

  5. 背水一战 Windows 10 (43) - C# 7.0 新特性

    背水一战 Windows 10 (43) - C# 7.0 新特性 原文: 背水一战 Windows 10 (43) - C# 7.0 新特性 [源码下载] 背水一战 Windows 10 (43) ...

  6. PHP 关于thinkphp5.0使用Imagick

    PHP输出画布已经是非常常见的功能,通常使用的都是imagecreatetruecolor()来创建画布,但是有和重要的问题无法修改"分辨率" . 在网页中显示72dpi就足够了, ...

  7. php7.0 + mysql5.7.10 + nginx7.0 web开发环境搭建(CentOS7)

    一.搭建nginx开发环境 参考官方文档:http://nginx.org/en/linux_pac... 1.设置yum 官当提供了利用yum来安装.升级nginx的方法 在/etc/yum.rep ...

  8. php 开启imagick,PHP-Imagick:在Imagick项目上设置重力

    在Imagick中设置图像的重力时,我遇到了一些实际困难. 我已经成功设置了ImaickDraw对象的重力,但是我没有成功在Imagick对象中设置它. 以下是此刻我正在使用的基本代码.我只是使用了与 ...

  9. Centos+Nginx+PHP7.0编译安装(和PHP5.6老版本共存)

    来源:http://blog.csdn.net/liuxinmingcode/article/details/50319145 场景 LNMP  当前版本:PHP 5.5.7  为了体验PHP7的速度 ...

最新文章

  1. zzfrom水木-Linux环境学习和开发心得(作者:lunker)
  2. 11寸笔记本电脑推荐_3000-20000元高性价比笔记本电脑推荐 含CPU天梯图、显卡天梯图 2020年11月更新...
  3. python gevent服务器_python gevent 协程
  4. 更改主机名后mysql无法启动_主机名变更导致MySql启动失败
  5. android环境搭建—— 工欲善其事必先利其器
  6. 【李宏毅2020 ML/DL】P59 Unsupervised Learning - Auto-encoder
  7. aaa logo汉子字体_AAA Logo –标志设计软件
  8. 通信协议:CAN总线
  9. 丰田、雷克萨斯决定在今年将亚马逊Alexa应用到部分车型中
  10. Putty(菩提)远程连接服务器教程听语音
  11. 在线生成网站地图工具SiteMap
  12. 香港中文大学计算机专业学费,香港中文大学研究生专业学费是多少?
  13. 【官宣】.NET 6 正式版来了
  14. 干货 | 因果推断在项目价值评估中的应用
  15. 简报 | 呼吁建立全球性加密货币征税体系和法规 或在2020年最终敲定
  16. iView 中 render 用法总结
  17. 老子说:知其雄,守其雌
  18. xposed微信红包
  19. 斐讯k3安装MySQL_PHICOMM斐讯K3无线路由器快速配置安装教程
  20. 与servere.exe的战斗历程

热门文章

  1. VC++ - 各种DC及DC资源释放
  2. 母婴电商品牌为什么要做私域运营?看看这个客户案例
  3. 事关健康 你不得不知的打印机常识
  4. EasyDSS平台无法登录Web页面的排查与解决方法
  5. 服装商城管理系统日常小结1
  6. php读取word格式,php读取word格式 phpword 读取word内容
  7. jdk1.6 eclipse kepler 中安装jda
  8. 【高通方案SDM845 Android10.0】 User版本支持fastboot升级 User版本和Userdebug版本互刷
  9. 屏的像素与传输速率_高像素时代 究竟多少万像素才够你用?
  10. 2017版MySQL DBA核心课程-第1-16部完整-老男孩-专题视频课程