Install the ImageMagick PHP extension in Windows

ImageMagick extension can be useful in many ways. It allows us to create, read, edit, and compose bitmap images easily.

If we have to install the imagick PHP extension on windows, then first we need to know the version of PHP you are using. To do the same, the following are the command we have provided to know the PHP version and architecture.

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

One we determined the above parameters, you can download the DLL of the extensions from the following link.

Download DLL from this link

Once you downloaded the 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 ImageMagick-….zip the DLL files located in the bin the folder that starts with CORE_RL or IM_MOD_RL, 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)

You can run the following code to the test if the extension is working.

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