Lashae
Lashae

Reputation: 1382

PHP-Imagick on OSX, ImagickException: NoDecodeDelegateForThisImageFormat `/my-path/file.jpg' @ error/constitute.c/ReadImage/550

My environment is: MacOSX 10.8.3, PHP 5.3.17, ImageMagick 6.8.0, Apache 2.2.22

I have installed ImageMagick and PHP-Imagick module by using macports.

ImageMagick works as expected, for example I can convert a JPG to GIF by using the console command convert /my-path/file.jpg file.gif.

However when I create a new Imagick instance by using a sample code as follow:

<?php
  $m = new Imagick('/my-path/file.jpg');

I get the exception:

NoDecodeDelegateForThisImageFormat `/my-path/file.jpg' @ error/constitute.c/ReadImage/550

The format of the file doesnt change the result; I tested different JPG, GIF and PNG images however same exception occurs.

So I suspect, the PHP/Apache - ImageMagick integration part is somewhat faulty.

I saw this post on SO and applied the given resolution (adding the environment variable "MAGICKCODERMODULE_PATH" with the value "/opt/local/lib/ImageMagick-6.8.0/modules-Q16/coders") however that didn't make sense for my case. (I confirmed the existence of this environment variable from my phpinfo)

Outputs of some commands on my system:

I will appreciate any suggestion.

Apache Configuration, Environment and PHPImagick Configuration

Upvotes: 2

Views: 1428

Answers (2)

Lashae
Lashae

Reputation: 1382

Solution

chmod 755 /opt

Insight and Thoughts

At last. I managed to solve the problem.

As there were no answers and suggestions on SO; I'm not suprised that something not expected was causing it!..

@sathia suggested to define an environment variable to call ImageMagick binaries. However in my case, I need to use phpImagick extension and access ImageMagick through its API, so this suggestion didn't make sense.

But I wanted to give it a try and call ImageMagick's convert binary by using PHP's system function. After calling it, I got a return value of "126"; and 126 means, binary is found however it's not executable!..

I checked the binary in /opt/local/bin/convert and it has appropriate execute permissions, then I checked /opt/local/bin and /opt/local directories as well and they were executable too. However the catch was /opt folder's permission was 700!

I managed to execute chmod 755 /opt and magically error has gone.

Upvotes: 4

prcvcc
prcvcc

Reputation: 2230

I've been there too, this is how I solved it:

<?php    

    define("IMAGE_MAGICK_PATH","/usr/local/bin/");
    $in = '/my-path/file.jpg';
    $out = '/my-path/file.gif';
    $convertString = IMAGE_MAGICK_PATH." convert ".$yourfile." ".$out;
    exec($convertString);

hope it helps

Upvotes: 1

Related Questions