The Computer Oracle

Convert PDF to JPG images with ImageMagick - how to 0-pad file names?

--------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: A Thousand Exotic Places Looping v001

--

Chapters
00:00 Question
00:41 Accepted answer (Score 40)
01:24 Thank you

--

Full question
https://superuser.com/questions/633698/c...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#imagemagick

#avk47



ACCEPTED ANSWER

Score 40


ImageMagick accepts format specifiers in its command line:

convert -density 600 foo.pdf foo-%02d.jpg

Quote from the doc:

Filename References

Optionally, use an embedded formatting character to write a sequential image list. Suppose our output filename is image-%d.jpg and our image list includes 3 images. You can expect these images files to be written:

image-0.jpg
image-1.jpg
image-2.jpg