Install Imagick for PHP and Apache on Windows
EDIT: This procedure works with Windows 7 - 10 and all versions of PHP as well.
Unofficial sites may be discontinued or later be altered to contain malicious code instead. Please use caution when using any recommended links or mirrors other than the official ImageMagick, PECL, or PHP sites provided in comments or other answers.
I was unable to get Imagick Working with PHP using an older release of ImageMagick as in the originally accepted answer and it was difficult to find mirrors with the exact safe binaries needed (the binaries on the mirror in the originally accepted answer downloaded as different versions than listed)
In all of the steps below, be sure to match your PHP architecture (x86/x64 and NTS/TS) to the binary's architecture. If you are using PHP x86 - replace the x64 version of the downloads with the x86 (or 32bit) version. The same applies to Thread-Safe (TS) and Non-Thread-Safe (NTS) versions of PHP.
PHP Imagick Extension
- Navigate to https://pecl.php.net/package/imagick
and download the latest DLL(3.3.0RC1)
at time of this answer. - Extract
php_imagick.dll
toD:\php5.6\ext
- Extract all
CORE_RL_*.dll
files toD:\php5.6
- - Ensure
D:\php5.6
is already added to thePATH
of your system environment variables - Add
extension = php_imagick.dll
toD:\php5.6\php.ini
- Restart Apache, PHP-FPM, or PHP Built-In Web Server
- Check
phpinfo();
to ensure the module is installed correctly Note the highlighted ImageMagick version(ImageMagick 6.9.1-2 Q16 x64)
and the missing supported formats
ImageMagick Binary
- (1a) Download and install the matching version of ImageMagick to
D:\php5.6\bin
from https://www.imagemagick.org/script/download.php - Ensure that theAdd Path to Environment Variables
option is checked or manually add it - (1b) Alternatively download the PECL dependencies for your version of the Imagick PECL extension, see below for more details.
- Load a command prompt (run as administrator which forces the system path variable to refresh) and ensure
convert --version
displays the correct version - Delete the previously extracted
CORE_RL_*.dll
files inD:\php5.6
(they will be loaded via ImageMagick path - otherwise your PHP installation may become unstable with the PECL dlls) - Restart Apache, PHP-FPM, or PHP Built-In Web Server
- Check
phpinfo();
to ensure the module is still installed correctly and is now loading the Imagick supported formats
Imagick PDF as Image Support - Ghostscript (optional)
- Optionally download and install Ghostscript to
D:\php5.6\bin
to be able to convert PDFs to images from http://sourceforge.net/projects/ghostscript/ be sure to match the architecture for your installation
I did not need to add MAGICK_HOME
for Imagick to work using the PHP Built-In Web Server or CGI, but may be required for Apache using mod_php
. See the Special Considerations section below for additional details.
PECL Imagick Dependencies (1b)
You can alternatively download the required ImageMagick version dependencies and extract the exe
and dll
files from within the bin
directory directly into your D:\php5.6
directory.
The dependencies can be found on PECL website http://windows.php.net/downloads/pecl/deps/
Using the PECL dependencies removes the need to directly download and
run the matching ImageMagick version installer from the vendor's website.
With the PECL dependencies method there were issues with excluded files needed for PDF conversions using GhostScript.
Special Considerations
Be sure the user running PHP has permission to execute convert
. This should be inherited via D:\php5.6\bin
but in case you chose to install to C:\Program Files
. you may have issues due to its restricted permissions.
Be sure to rearrange your PATH
System Environment Variable so that %SystemRoot%\system32\convert.exe
does not override the D:\php5.6\bin\convert.exe
.
By adding your PHP path to the left of system32, like so: PATH: D:\php5.6\bin;%SystemRoot%\system32;%SystemRoot%;...
This will force your system to look for executable files within D:\php5.6\bin
prior to %SystemRoot%\system32
Replace D:\php5.6\bin\convert.exe
with the path to where you installed ImageMagick or the path to where convert.exe
is located
https://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection127121120120
How to install php_imagick on wamp64
I hired a freelancer to fix this for us.
- Uninstall any versions of WampServer and ImageMagick you have installed
- Don't forget to backup your database and www folder before you uninstall
- We are going to install a trustable software called Chocolatey that will help us fix a bunch of errors with Wamp64 and it's extensions as well as help us update those applications with one command.
For those of you who already fixed this before using Chocolatey and
now seeing this error message again simply update Wamp and ImageMagick
using the choco commands provided on their website and then read my
note under4)
for more information
Run PowerShell as Admin
- Follow this guide to Download chocolatey https://chocolatey.org/install
Use the same methods to Download Wamp64 https://chocolatey.org/packages/wamp-server
- Run Wamp from the newly created shortcut on your desktop
- Change the PHP version to 7.4.9 or the latest and only then move
to the other steps - Don't worry about the fact the folder is named Wamp and not Wamp64. It's still the 64bit version. You can check this in the about section of Wamp
Download https://chocolatey.org/packages/imagemagick
Download https://windows.php.net/downloads/pecl/deps/ImageMagick-7.0.7-11-vc15-x64.zip
- Note: If that doesn't work, they probably updated again. Just try the same methods using newer versions then these. I will first try more recent versions of php_imagick instead of replacing the ImageMagick core DLL files. One thing I will not do is give up.
Extract And Copy all
CORE_RL
andIM_MOD_RL
DLL files intoC:\wamp\bin\php\php7.4.9
wherephp.exe
is located(Do not run any EXE file from here as we already installed ImageMagick)
Download https://windows.php.net/downloads/pecl/releases/imagick/3.4.4/php_imagick-3.4.4-7.4-ts-vc15-x64.zip
Extract and Copy just the
php_imagick.dll
file toC:\wamp\bin\php\php7.4.9\ext
Open your php.ini file by left-clicking Wamp->PHP->php.ini and then make sure you delete all leftovers and add below any
extention=
line the code below:
extention=imagick
(Apparently, New PHP versions require writing it without the "php_"...".dll" parts)
- Restart Wamp by closing it and reopening it from its shortcut
This is by far the only solution I could get running.
choco:
Google = https://www.google.com/search?q=chocolatey
2019 = http://web.archive.org/web/20190101113929/https://chocolatey.org/
2018 = http://web.archive.org/web/20180414000310/https://chocolatey.org/
Enjoy
How to install Imagick/imagemagick PHP extension on windows 7
Check permissions on the .dll file to make sure the Apache user has read access to the file. Better change the permission of the [PHP]/extension directory.
To change the permission
- Right click the file(s) or folder(s)
- Select "Properties"
- Select "Security" tab
- Click on "Edit" button.
Change the permission of user to Full Control.
How to install ImageMagick to use with PHP on Windows 7 (3)
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/.
This is not the latest version but it worked. (even without restarting the computer)
Related Topics
How to Sort an Array of Utf-8 Strings in PHP
How to Sum N Number of Time (Hh:Mm Format)
What Is a Factory Design Pattern in PHP
Regular Expression to Collect Everything After the Last /
Add a Prefix to Each Item of a PHP Array
Include, Include_Once, Require or Require_Once
How to Get the Os on Which PHP Is Running
Why Does Password_Verify Return False
How to Call a Model from a View
How to Get MAC Address of Client Using PHP
PHP Exec $Path Variable Missing Elements
Best Practices: Working with Long, Multiline Strings in PHP
Laravel 5.5 the Page Has Expired Due to Inactivity. Please Refresh and Try Again