Theres a way, using PHP exec and Image MagicK, to get the first PDF page and convert it to JPG?
Asked
Active
Viewed 1.4k times
6
-
1possible duplicate of [Imagemagick convert pdf to png](http://stackoverflow.com/questions/1811640/imagemagick-convert-pdf-to-png) – Pekka Feb 10 '11 at 18:02
2 Answers
6
To answer your question, you convert just the nth page page as follows:
convert file.pdf[n] output_file.jpg
Note that this is zero based, so for the first page you would want to use file.pdf[0]
.
If you wish to convert the entire file, you can do:
convert file.pdf output_file.jpg
And this will produce a bunch of files in the form of output_file-0.jpg, output_file-1.jpg, ..., output_file-n.jpg

mfonda
- 7,873
- 1
- 26
- 30
4
There are many search results on SO already.
You have the choice between two duplicates:
ImageMagick/Imagick convert PDF to JPG using native PHP API using the PHP IM bindings
Imagemagick convert pdf to png using the command line.
Note that for this to work, you need Ghostscript installed along with ImageMagick. (I think this usually is the case.)