PHP Fatal error: Uncaught exception 'ImagickEx

2019-07-06 12:29发布

问题:

I'm using an AWS EC2 Bitnami AMI: bitnami-lampstack-5.4.11-1-linux-ubuntu-12.04.1-x86_64-ebs (ami-aadf4cc3)

I have a php file:

<?php 
    $im = new imagick();
    $im->readImageBlob(file_get_contents("http://s3.amazonaws.com/bucket/file.jpg"));
?>

That gives me the following error:

PHP Fatal error:  Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `' @ error/blob.c/BlobToImage/361' in /opt/bitnami/apache2/htdocs/index.php:3
Stack trace:
#0 /opt/bitnami/apache2/htdocs/index.php(3): Imagick->readimageblob('??????JFIF?????...')
#1 {main}
  thrown in /opt/bitnami/apache2/htdocs/index.php on line 3

I installed imagick using the following steps:

1) wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz
    2) tar -zxvf imagick-3.1.0RC2.tgz
    3) cd imagick-3.1.0RC2
    4) phpize
    5) ./configure
    6) make
    7) make install

So far, I've tried:

1) file_get_contents is returning the image file and it is a confirmed jpeg
2) using convert directly from the command line --> it works
3) imagick-3.0.1 on this AMI and it won't install because of compiler errors
4) imagick-3.0.1 on the previous bitnami AMI (bitnami-lampstack-5.3.10-2-linux-ubuntu-12.04-x86_64-ebs (ami-8c4c96e5)) and it gives the same ImagickException error (no decode delegate)
5) Using a PNG file which gives me the same error

Convert -list configure gives me DELEGATES bzlib freetype jpeg jng png tiff zlib

回答1:

Solution:

update /opt/bitnami/scripts/setenv.sh as follows with

MAGICKCODERMODULE_PATH="/usr/lib/ImageMagick-6.6.9/modules-Q16/coders"

THEN

`/opt/bitnami/ctlscript.sh restart apache`