windows下php imagick 报错 ​no decode delegate for this image format `JPEG' 的解决方法

windows下使用 php imagick 时报错:no decode delegate for this image format `JPEG' @ error/constitute.c/ReadImage/501

或者 no decode delegate for this image format `PNG'

或者 no decode delegate for this image format `BMP'


原因:IM_MOD_ 安装不完整

解决方法:根据 https://mlocati.github.io/articles/php-windows-imagick.html 提示,完整安装 imagick 

下载对应的版本:

VersionThread SafeArchitectureEstensionImageMagick
7.0Yesx86php_imagick-3.4.3-7.0-ts-vc14-x86.zipImageMagick-6.9.3-7-vc14-x86.zip
7.0Yesx64php_imagick-3.4.3-7.0-ts-vc14-x64.zipImageMagick-6.9.3-7-vc14-x64.zip
7.0Nox86php_imagick-3.4.3-7.0-nts-vc14-x86.zipImageMagick-6.9.3-7-vc14-x86.zip
7.0Nox64php_imagick-3.4.3-7.0-nts-vc14-x64.zipImageMagick-6.9.3-7-vc14-x64.zip


Once you downloaded the correct files:

  1. 解压 php_imagick-….zip  php_imagick.dll 放到php的 ext 目录

  2. 解压 ImageMagick-….zip 把以下字母开头的DLL文件放到PHP的根目录,即  php.exe 所在目录, or to a directory present in your PATH environment variable,:

  3. 在 php.ini 中添加: extension=php_imagick.dll

  4. 重启 Apache/NGINX Windows 等web服务

现在测试一下,看看是否正常运行:

<?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'; 


以上是以php7为例,其它版本请参照以下方法查找:



根据上面查到的信息,下载适合的版本

VersionThread SafeArchitectureEstensionImageMagick
5.5Yesx86php_imagick-3.4.3-5.5-ts-vc11-x86.zipImageMagick-6.9.3-7-vc11-x86.zip
5.5Yesx64php_imagick-3.4.3-5.5-ts-vc11-x64.zipImageMagick-6.9.3-7-vc11-x64.zip
5.5Nox86php_imagick-3.4.3-5.5-nts-vc11-x86.zipImageMagick-6.9.3-7-vc11-x86.zip
5.5Nox64php_imagick-3.4.3-5.5-nts-vc11-x64.zipImageMagick-6.9.3-7-vc11-x64.zip
5.6Yesx86php_imagick-3.4.3-5.6-ts-vc11-x86.zipImageMagick-6.9.3-7-vc11-x86.zip
5.6Yesx64php_imagick-3.4.3-5.6-ts-vc11-x64.zipImageMagick-6.9.3-7-vc11-x64.zip
5.6Nox86php_imagick-3.4.3-5.6-nts-vc11-x86.zipImageMagick-6.9.3-7-vc11-x86.zip
5.6Nox64php_imagick-3.4.3-5.6-nts-vc11-x64.zipImageMagick-6.9.3-7-vc11-x64.zip
7.0Yesx86php_imagick-3.4.3-7.0-ts-vc14-x86.zipImageMagick-6.9.3-7-vc14-x86.zip
7.0Yesx64php_imagick-3.4.3-7.0-ts-vc14-x64.zipImageMagick-6.9.3-7-vc14-x64.zip
7.0Nox86php_imagick-3.4.3-7.0-nts-vc14-x86.zipImageMagick-6.9.3-7-vc14-x86.zip
7.0Nox64php_imagick-3.4.3-7.0-nts-vc14-x64.zipImageMagick-6.9.3-7-vc14-x64.zip
7.1Yesx86php_imagick-3.4.3-7.1-ts-vc14-x86.zipImageMagick-6.9.3-7-vc14-x86.zip
7.1Yesx64php_imagick-3.4.3-7.1-ts-vc14-x64.zipImageMagick-6.9.3-7-vc14-x64.zip
7.1Nox86php_imagick-3.4.3-7.1-nts-vc14-x86.zipImageMagick-6.9.3-7-vc14-x86.zip
7.1Nox64php_imagick-3.4.3-7.1-nts-vc14-x64.zipImageMagick-6.9.3-7-vc14-x64.zip
7.2Yesx86php_imagick-3.4.3-7.2-ts-vc15-x86.zipImageMagick-7.0.7-11-vc15-x86.zip
7.2Yesx64php_imagick-3.4.3-7.2-ts-vc15-x64.zipImageMagick-7.0.7-11-vc15-x64.zip
7.2Nox86php_imagick-3.4.3-7.2-nts-vc15-x86.zipImageMagick-7.0.7-11-vc15-x86.zip
7.2Nox64php_imagick-3.4.3-7.2-nts-vc15-x64.zipImageMagick-7.0.7-11-vc15-x64.zip


发表评论

必填

选填

选填

必填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。