Install the ImageMagick PHP extension in Windows
NOTE I recently released a PowerShell module that will let you install the PHP imagick extension simply with Install-PhpExtension imagick
In order to install the imagick PHP extension on Windows, you need to know the exact version of your PHP. To do this: open a command prompt and enter these commands:
-
Determine the PHP version:
php -i|find "PHP Version"
-
Determine the thread safety
php -i|find "Thread Safety"
You’ll haveenabled
for thread safe ordisabled
for not thread safe -
Determine the architecture
php -i|find "Architecture"
You’ll havex86
for 32 bits andx64
for 64 bits
Once you determined the above parameters, you have to download the dll of the PHP extension and the ImageMagick archive using the following table:
Filter
Once you downloaded the correct files:
- Extract from
php_imagick-….zip
thephp_imagick.dll
file, and save it to theext
directory of your PHP installation - Extract from
php_imagick-….zip
the other DLL files (they may start withCORE_RL
,FILTER
,IM_MOD_RL
, orImageMagickObject
depending on the version), and save them to the PHP root directory (where you havephp.exe
), or to a directory in yourPATH
variable - Add this line to your
php.ini
file:
extension=php_imagick.dll
- Restart the Apache/NGINX Windows service (if applicable)
To test if the extension works, you can run this PHP code:
<?php
$image = new Imagick();
$image->newImage(1, 1, new ImagickPixel('#ffffff'));
$image->setImageFormat('png');
$pngData = $image->getImagesBlob();
echo strpos($pngData, "\x89PNG\r\n\x1a\n") === 0 ? 'Ok' : 'Failed';