开发者

How do I process jpg files using ImageMagick (IMagick API)? I am getting an exception, NoDecodeDelegateForThisImageFormat, whenver I try

I am using ImageMagick with the PHP IMagick API to process uploaded jpg files - however, when I try to read a Blob or even read a physical file, I get a NoDecodeDelegateForThisImageFormat exception.

An example of the code I am using is below:

private function resizeImageBlob($blob, $width, $height) {
    $image = new Imagick();
    $image->readImageBlob($blob);
    $image->resizeImage($width, $height, IMAGICK::FILTER_LANCZOS, 1);
    $resizedBlob = $image->getImageBlob();

    return $resizedBlob;
}

The image that the blob represents is a jpg image, but ImageMagick throws the exception when it tries to read the line:

$image->readImageBlob($blob);

Does anybody know why开发者_运维知识库 this might be happening?


I figured out the answer to my problem. The reason the exception was occurring was indeed due to the fact that the library did not have jpeg support built in, but the reason this happened was because the Imagick php extension's version and the ImageMagick library's version were different.

A good way to make sure not to run into this problem is to download both the ImageMagick library and the Imagick php extension, and specifically look at the versions to see that they match.

Alternatively, you can check the version of your Imagick php extension in the php/ext folder by enabling it in your php.ini file, and using

echo phpinfo();

to check the version of the extension. Then, you can download the same version of the ImageMagick library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜