Andrew McCombe

Full Stack Web Developer

PHP imagick ImagickException no decode delegate for postscript or PDF files

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.

Drawing an Arc in Imagick

Here’s how to draw an arc using PHP Imagick $canvas = new Imagick(); $canvas->newImage(200, 200, new ImagickPixel(“white”),’png’); $arc = new ImagickDraw(); $arc->setFillColor(‘red’); $arc->setStrokeColor(‘black’); $arc->setStrokeWidth(2); /* x1,x2,y1,y2, start angle, end angle */ $arc->arc(30, 30, 160, 160, -70, 70); $canvas->drawImage($arc); $canvas->borderImage(‘black’, 1, 1); header(‘content-type: image/png’); echo $canvas->getImage(); exit(); Produces:

Installing and using PHP ImageMagick (Imagick) Module

Installation On an Ubuntu System: sudo apt-get install imagemagick libmagick9-dev php5-imagick php5-dev wget tar xvfz imagick-3.0.0b1.tgz cd imagick-3.0.0b1 phpize && ./configure sudo make sudo make install sudo apache2ctl graceful Example Usage: < ?php //Create two Imagick objects $first = new Imagick('tshirt.png'); $second = new Imagick('photo.jpg'); $first->compositeImage($second, Imagick::COMPOSITE_MULTIPLY, 220, 141); //new image is saved as […]