在windows 的 xampp/php 上安装 ImageMagick extension

ImageMagick 安装版本下载

在 xampp-win32-5.6.38-0-VC11 上安装

检查windows上php版本

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

根据php版本参数,下载对应的 ImageMagick 和 php_imagick 模块

地址:

安装 php_imagick

  1. php_imagick-….zip解压出php_imagick.dll,放到ext目录
  2. ImageMagick-….zip解压出,文件名以CORE_RL or IM_MOD_RL开头的 DLL,放到 php.exe 所在的目录(这个目录应该已经配置到PATH)。
    或者,拷贝到其他目录,这个目录应该配置到PATH。
  3. Add this line to your php.ini file: extension=php_imagick.dll
  4. Restart the Apache/NGINX Windows service (if applicable)

测试

1
2
3
4
5
6
<?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';