This has been asked before but the answer is always to use ghost script. This isn't available on hosts using cPanel. Is it possible to do without Ghostscript extension installed?
-
Who says a server with cpanel can't have ghostscript? – ceejayoz Nov 16 '11 at 02:32
-
1Well not all hosting companies install ghostscript by default. Some of it requires the owner to install it themself. Maybe Tim does not want to install it? – iWantSimpleLife Nov 16 '11 at 03:25
-
My hosting co says cpanel servers can't have ghostscript. is that wrong? – Will Nov 23 '11 at 06:01
-
They certainly *can* have Ghostscript. If anything, I might imagine there could be some security aspect of Ghostscript that makes it undesirable, but I don't know what that would be. – Dolda2000 Mar 26 '12 at 22:07
3 Answers
Just a quick suggestion for those considering using an external service to achieve this: now, some APIs allow to upload documents and retrieve their related info, thumbnail, etc.
For instance see Cloudinary (which offers a free plan) : https://cloudinary.com/blog/uploading_converting_and_generating_thumbnails_for_pdf_documents

- 11
- 1
You could compile a single binary of Imagemagick and deploy that to the webserver, like this guy. His issue sounds much like yours
I need to deploy ImageMagick's "convert" utility on a a shared host, where I don't have access to /usr/lib, env or anything else except the webspace. I can however drop a binary into the webspace, chmod it to 755 and run it (from the Apache context).
Building the standalone binary means it can include ghostscript as part of the binary. If you can't build on the target host, use a VM with the same OS, build the binary, then upload that to your webroot and call it w/ exec
et al

- 66,362
- 10
- 68
- 89
You need ImageMagick and GhostScript.
<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;
?>
The [0]
means page 1.

- 19,824
- 17
- 99
- 186

- 485
- 4
- 12
- 26
-
Imagemagick needs Ghoscript to read PDF files, but not to save to PDF from some other format. Sorry, I do not know any other tools that would read PDF to convert to some other format. – fmw42 May 26 '17 at 17:24