Last Updated: February 25, 2016
·
5.783K
· sagark

Using ImageMagick PHP extension to convert PDF image to thumbnails .

*1.Install imagemagick in ubuntu *

sudo apt-get install imagemagick

2.Install imagemagick PECL extension

sudo apt-get install php5-imagick

Restart apache web server

sudo service apache2 restart

PHP script

<?php $im = new imagick('file.pdf[0]'); $im->setImageFormat('jpg'); header('Content-Type: image/jpeg'); echo $im; ?>

Note that the file name is file.pdf .

You can also resize the image by adding the following line

$im->thumbnail(200,200);

This will resize the image into 200*200.
For more info read this -

www.sitepoint.com/crop-and-resize-images-with-imagemagick/