1

I use this command in my shell to convert from PDF to image

convert -density 150x150 <PDF filename> -append -quality 100 <Image filename>

The PDF has four pages, but I only need the last two. How can I remove the first two pages from the PDF and convert the ones which remain to an image?

Lightness Races in Orbit
  • 369,052
  • 73
  • 620
  • 1,021
Centurion
  • 4,949
  • 6
  • 25
  • 46
  • 2
    This is not a php question. You should find the documentation of this convert tool, whatever it may be. – GolezTrol Jun 09 '11 at 14:26
  • @GolezTrol: Agreed. It's like writing the code `$a = 5 + 2;` and expecting the result `8`, then tagging it PHP because you happened to run into your mathematical misunderstanding whilst writing PHP. – Lightness Races in Orbit Jun 09 '11 at 14:35

1 Answers1

5

I assume you are using ImageMagick in combination with GhostScript. You can specify the page number of the PDF like this:

convert -density 150x150 <PDF filename>[0] -append -quality 100 <Image filename>

where 0 is the page number minus 1 (indexing starts at 0).

In your special case it would be

convert -density 150x150 <PDF filename>[2] <PDF filename>[3] -append -quality 100 <Image filename>
DanielB
  • 19,386
  • 2
  • 42
  • 49