/** * Get a preview thumbnail for a pdf * @param string $blob * @param integer $width * @param integer $height * * @return blob */ public static function thumbnailPDF($blob, $width, $height) { try { $im = new imagick(); $im->readimageblob($blob); $im->setiteratorindex(0); $im->setImageFormat("png"); $im->scaleimage($width, $height); } catch (ImagickException $e) { $im = new imagick(); $im->readimage(realpath(__DIR__ . '/media/default_pdf_logo.png')); $im->scaleimage($width, $height); } return $im->getimageblob(); }