Php imagick save to file

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:

VersionThread SafeArchitectureEstension
5.5 Yes x86 php_imagick-3.4.3-5.5-ts-vc11-x86.zip
5.5 Yes x64 php_imagick-3.4.3-5.5-ts-vc11-x64.zip
5.5 No x86 php_imagick-3.4.3-5.5-nts-vc11-x86.zip
5.5 No x64 php_imagick-3.4.3-5.5-nts-vc11-x64.zip
5.6 Yes x86 php_imagick-3.4.3-5.6-ts-vc11-x86.zip
5.6 Yes x64 php_imagick-3.4.3-5.6-ts-vc11-x64.zip
5.6 No x86 php_imagick-3.4.3-5.6-nts-vc11-x86.zip
5.6 No x64 php_imagick-3.4.3-5.6-nts-vc11-x64.zip
7.0 Yes x86 php_imagick-3.4.3-7.0-ts-vc14-x86.zip
7.0 Yes x64 php_imagick-3.4.3-7.0-ts-vc14-x64.zip
7.0 No x86 php_imagick-3.4.3-7.0-nts-vc14-x86.zip
7.0 No x64 php_imagick-3.4.3-7.0-nts-vc14-x64.zip
7.1 Yes x86 php_imagick-3.4.4-7.1-ts-vc14-x86.zip
7.1 Yes x64 php_imagick-3.4.4-7.1-ts-vc14-x64.zip
7.1 No x86 php_imagick-3.4.4-7.1-nts-vc14-x86.zip
7.1 No x64 php_imagick-3.4.4-7.1-nts-vc14-x64.zip
7.2 Yes x86 php_imagick-3.4.4-7.2-ts-vc15-x86.zip
7.2 Yes x64 php_imagick-3.4.4-7.2-ts-vc15-x64.zip
7.2 No x86 php_imagick-3.4.4-7.2-nts-vc15-x86.zip
7.2 No x64 php_imagick-3.4.4-7.2-nts-vc15-x64.zip
7.3 Yes x86 php_imagick-3.6.0-7.3-ts-vc15-x86.zip
7.3 Yes x64 php_imagick-3.6.0-7.3-ts-vc15-x64.zip
7.3 No x86 php_imagick-3.6.0-7.3-nts-vc15-x86.zip
7.3 No x64 php_imagick-3.6.0-7.3-nts-vc15-x64.zip
7.4 Yes x86 php_imagick-3.7.0-7.4-ts-vc15-x86.zip
7.4 Yes x64 php_imagick-3.7.0-7.4-ts-vc15-x64.zip
7.4 No x86 php_imagick-3.7.0-7.4-nts-vc15-x86.zip
7.4 No x64 php_imagick-3.7.0-7.4-nts-vc15-x64.zip
8.0 Yes x86 php_imagick-3.7.0-8.0-ts-vs16-x86.zip
8.0 Yes x64 php_imagick-3.7.0-8.0-ts-vs16-x64.zip
8.0 No x86 php_imagick-3.7.0-8.0-nts-vs16-x86.zip
8.0 No x64 php_imagick-3.7.0-8.0-nts-vs16-x64.zip
8.1 Yes x86 php_imagick-3.7.0-8.1-ts-vs16-x86.zip
8.1 Yes x64 php_imagick-3.7.0-8.1-ts-vs16-x64.zip
8.1 No x86 php_imagick-3.7.0-8.1-nts-vs16-x86.zip
8.1 No x64 php_imagick-3.7.0-8.1-nts-vs16-x64.zip

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:
    extension=php_imagick.dll
  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'));
$image->setImageFormat('png');
$pngData = $image->getImagesBlob();
echo strpos($pngData, "\x89PNG\r\n\x1a\n") === 0 ? 'Ok' : 'Failed'; 

What does PHP imagick do?

Imagick is a PHP extension to create and modify images using the ImageMagick library. There is also a version of Imagick available for HHVM. Although the two extensions are mostly compatible in their API, and they both call the ImageMagick library, the two extensions are completely separate code-bases.

What is the use of imagick?

Use ImageMagick® to create, edit, compose, or convert digital images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, WebP, HEIC, SVG, PDF, DPX, EXR and TIFF.

What is imagick library?

Imagick and GD are popular image optimization libraries in PHP applications. While they both perform many of the same actions, they operate a bit different from each other and offer different benefits. Overall, these two libraries are used for: Resizing/cropping images. Modifying the contents of an image.

Is imagick the same as ImageMagick?

ImageMagick is a PHP utility, a command line tool for image manipulation. For further details, see this. Imagick is an API or a class that performs the function same as ImageMagick. It provides numerous functions for image manipulation in PHP.