6

Theres a way, using PHP exec and Image MagicK, to get the first PDF page and convert it to JPG?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • 1
    possible 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 Answers2

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:

Note that for this to work, you need Ghostscript installed along with ImageMagick. (I think this usually is the case.)

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088