Search code examples
phppdfimagick

Generate Thumbnail from pdf 1st page using Imagick PHP


I am trying to convert my pdf file first page to thumbnail and I already installed ImageMagick and GhostScript for this purpose. Imagick extension successfully installed and showed up in phpinfo(). But I am getting the below error:

enter image description here

Below is my code:

$image = new Imagick($_SERVER['DOCUMENT_ROOT'] . '/convert-pdf/file.pdf[0]');

$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;

Solution

  • You have $image and are using $im; try changing $image to $im.