Install the ImageMagick PHP extension in Windows

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 have enabled for thread safe or disabled for not thread safe

  • Determine the architecture
    php -i|find "Architecture"
    You’ll have x86 for 32 bits and x64 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:

Version Thread Safe Architecture Estension
5.5 Yes x86
5.5 Yes x64
5.5 No x86
5.5 No x64
5.6 Yes x86
5.6 Yes x64
5.6 No x86
5.6 No x64
7.0 Yes x86
7.0 Yes x64
7.0 No x86
7.0 No x64
7.1 Yes x86
7.1 Yes x64
7.1 No x86
7.1 No x64
7.2 Yes x86
7.2 Yes x64
7.2 No x86
7.2 No x64
7.3 Yes x86
7.3 Yes x64
7.3 No x86
7.3 No x64
7.4 Yes x86
7.4 Yes x64
7.4 No x86
7.4 No x64
8.0 Yes x86
8.0 Yes x64
8.0 No x86
8.0 No x64
8.1 Yes x86
8.1 Yes x64
8.1 No x86
8.1 No x64

Once you downloaded the correct files:

  1. Extract from php_imagick-….zip the php_imagick.dll file, and save it to the ext directory of your PHP installation
  2. Extract from php_imagick-….zip the other DLL files (they may start with CORE_RL, FILTER, IM_MOD_RL, or ImageMagickObject depending on the version), and save them to the PHP root directory (where you have php.exe), or to a directory in your PATH variable
  3. Add this line to your php.ini file:
  4. Restart the Apache/NGINX Windows service (if applicable)

To test if the extension works, you can run this PHP code:

$image = new Imagick();
$image->newImage(1, 1, new ImagickPixel('#ffffff'));
$pngData = $image->getImagesBlob();
echo strpos($pngData, "\x89PNG\r\n\x1a\n") === 0 ? 'Ok' : 'Failed';