0

I'm processing a boatload of images (in PHP 7.1) from an external server and most of them are working, but a few of them are not. I open these images separately and open fine in a browser and in Photoshop. These few images will not pass the readImageBlob() method of Imagick. Quick code:

$img = new Imagick();
if( $image = file_get_contents('http://my.url/image.jpg') !== false ){
    try{
        $img->readImageBlob( $image );
    } catch (Exception $e) {
        error_log('failed to open image');
    }
}

file_get_contents() is returning true in both the working images and the erroneous ones.

Without the try/catch in there, this is the error PHP is throwing:

Uncaught ImagickException: no decode delegate for this image format `' @ error/blob.c/BlobToImage/361

Also, when I use the GD library as a fallback method, it processes the image fine.

Talk Nerdy To Me
  • 626
  • 5
  • 21
  • maybe URL's of these few images does contain 'https' instead of 'http' ? by default `file_get_contents` may not work without `openssl` extension, see: https://stackoverflow.com/questions/1975461/how-to-get-file-get-contents-to-work-with-https – Mateusz Palichleb Jan 30 '18 at 21:36
  • @MateuszPalichleb Good stab, but unfortunately not the case. – Talk Nerdy To Me Jan 30 '18 at 21:40
  • Did you search at all? Many results, including a few here at SO for "no decode delegate". The issue seems to be that the correct library is not installed (or correctly installed) to read the image format. – timclutton Feb 01 '18 at 08:28
  • @timclutton I did unfortunately. All the correct libraries seem to be installed and in those answers, NONE of the images will process via Imagick and for me it's only select ones. I don't know what is special about some of these jpeg's that Imagick fails to process them while everything else does. – Talk Nerdy To Me Feb 01 '18 at 16:09
  • Can you attach a working image and a non-working image to your question? – timclutton Feb 01 '18 at 16:11

0 Answers0