PHP imagick ImagickException no decode delegate for postscript or PDF files


Posted by Andrew McCombe on Fri May 17, 2013

This morning I had an issue with a PHP imagick ImagickException when converting a PDF/postscript file to a thumbnail. I have PHP Imagick, Imagemagick and Ghostscript installed and everything verifies as OK in phpinfo output. The error is:

ImagickException: no decode delegate for this image format `/’ @ error/constitute.c/ReadImage/532

My code:

This is a known bug (see http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=11989) and is fixed in the latest releases. Unfortunately the fixes haven’t made it into our server’s packages yet (Ubuntu precise64 / PHP Imagick 3.1.0RC2). The fix is to read the file from a file pointer rather than direct.

Initially it worked but thumbnails were being generated with black backgounds. Adding the call to “$im->setColorSpace(imagick::COLORSPACE_RGB)” resolved that.

Many thanks to ├ůsmund Herikstad for posting the solution that led me to the issue at http://www.herikstad.net/2010/05/postscript-delegate-failed-for.html