I have used a docker container with the embedded php server for development. Now we are creating a test environment and we wanted to use php-fpm. Everything went fine and the whole thing works as expected, with one difference - ImageMagick.

The same command, executed from php embedded server and php-fpm yields different results:

When converting images using the embedded server it works just fine, but when using php-fpm, I get:

convert: no decode delegate for this image format `PNG' @ error/constitute.c/ReadImage/504.
convert: no images defined `-' @ error/convert.c/ConvertImageCommand/3258.

It's really frustrating because it's the same container, the same php installation, the same php.ini.

EDIT: Command used:

shell_exec("/usr/bin/convert -thumbnail "50x50+0+0" /app/assets/uploads/super_e55d4fbf182b582f5bb1_bottle05.png -");

EDIT2: I have tried executing something "simple", and here's the output:

‌Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org[...]

‌‌shell_exec("ls /app/assets/uploads/super_e55d4fbf182b582f5bb1_bottle05.png");

‌‌shell_exec("/usr/bin/identify /app/assets/uploads/super_e55d4fbf182b582f5bb1_bottle05.png");


‌‌shell_exec("/usr/bin/identify /app/assets/uploads/super_e55d4fbf182b582f5bb1_bottle05.png 2>&1");
‌identify-im6.q16: no decode delegate for this image format `PNG' @ error/constitute.c/ReadImage/504.

while executed directly in shell:

/usr/bin/identify /app/assets/uploads/super_e55d4fbf182b582f5bb1_bottle05.png 2>&1
/app/assets/uploads/super_e55d4fbf182b582f5bb1_bottle05.png PNG 520x1020 520x1020+0+0 8-bit sRGB 319KB 0.010u 0:00.009
  • What are you executing to get that error? – Michael Hampton Aug 9 '18 at 14:21
  • Sorry, I have missed the notification. I have updated the question. – Krystian Aug 10 '18 at 6:29
  • Why don't you use PHP's Imagick class directly, instead of calling out to the shell? This code smells to high heaven... – Michael Hampton Aug 10 '18 at 14:03
  • According to what we saw in the docs, in order to use the HEIC/HEIF conversions we have to use the latest imagick and it does not support that in the php module. So we do use a PHP library we have installed through composer which in turn uses the convert directly. – Krystian Aug 11 '18 at 21:13

I had to set the environment variables to correct values to make it work through shell_exec(). Those variables were not set in shell.


In my case:


I have made sure that my container will always get this specific version of image magick not to be surprised in the future, in my case:

RUN apt-get install -y imagemagick=8:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.