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 https://pecl.php.net/package/imagick/3.4.1/windows
Once you downloaded the files:
- Extract from
php_imagick.dllfile, and save it to the
extdirectory of your PHP installation
- Extract from
ImageMagick-….zipthe DLL files located in the
binthe folder that starts with
IM_MOD_RL, and save them to the PHP root directory (where you have
php.exe), or to a directory in your
- Add this line to your
- Restart the Apache/NGINX Windows service (if applicable)
You can run the following code to the test if the extension is working.
<?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';