Reputation: 554
I'm using Imagick and trying to convert a pdf to a png. It fails. My error_log says "Failed to read the file".
Example code:
$fileone = $_SERVER['DOCUMENT_ROOT'] . '/' . 'test.pdf';
$image = new Imagick($fileone);
$image->readImage($fileone);
$image->thumbnailImage(300, 0);
echo '<img src="data:image/png;base64,' . base64_encode($image->getimageblob()) . '" />';
Thoughts?
Upvotes: 5
Views: 9973
Reputation: 81
You need to install ghostscript
sudo apt-get install ghostscript
Upvotes: 7
Reputation: 331
I would first use realpath()
to check your file path and then see if the file is readable.
$fileone = realpath('test.pdf');
if (!is_readable($fileone)) {
echo 'file not readable';
}
Then if it is a multiple page pdf try this
$image = new Imagick($fileone.'[0]');
Upvotes: 2