Display file names when extracting page range from pdf in jpeg using Imagemagick

I am trying to extract a series of pages from a multi-page pdf file into separate jpegs using convert (Imagemagick). Mining works great. I am stuck with the fact that if I want to extract a range of pages 10-20, I still get jpeg files with the names page-0.jpeg for page-9.jpeg, while I want to be called page- 10.jpeg pp-20.jpeg. Is there a way to specify what is on the command line?

I need this because I want to extract pages into cartridges 10 in order to avoid too much memory for huge PDF files and do not want to rename files.

I remember that this worked in an earlier project, but I can’t understand what I’m missing right now.

+4
source share
1 answer

Finally managed to do it. Leaving the answer if someone is looking for the same. The solution works with Imagemagick 6.5.1.

So, we want to extract pages with numbers i in j from a.pdf into separate jpegs with files with names from-10.jpeg to a-20.jpeg.

convert a.pdf[ij] -set filename:page "%[fx:t+i]" a-%[filename:page].jpeg 

In this case, the fx operators are used. fx: t gives the screen number of the current image in sequence, and we can add our offset to it.

+13
source

All Articles