"Page" numbering when converting a multi page PDF

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

"Page" numbering when converting a multi page PDF

Post by whugemann »

The basic command is of course:
convert -density 150 input.pdf -compress group4 output-%02d.tif

or something alike. Numbering will however start at zero and thus the resulting file numbers will be the page numbers of the PDF minus one.
Is there any built-in way to modify this behaviour such that page numbers and file numbers coincide?
Wolfgang Hugemann
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: "Page" numbering when converting a multi page PDF

Post by fmw42 »

Use -scene 1 see http://www.imagemagick.org/script/comma ... lgp4#scene

convert rose: rose: rose: rose: rose.pdf
convert rose.pdf -scene 1 rose_%d.png

produces:
rose_1.png
rose_2.png
rose_3.png
rose_4.png
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: "Page" numbering when converting a multi page PDF

Post by whugemann »

Thank you, Fred, that does the trick!
You can even supply a negative value for -scene, as I have just tested. This is also a common task, because many PDFs contain start pages that have an irregular page count, say with Roman numbers. So the Arabic page number "1" may actually be the fifth page of the PDF (or whatever).
Wolfgang Hugemann
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: "Page" numbering when converting a multi page PDF

Post by anthony »

When saving the number you can force the number to always be output with either + or - as appropriate by using %+d or if you like a fixed set of numbers, (say 3 digits with leading zeros) %+03d This will make the filenames list in the right order!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply