need help with mogrify numbering

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
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: need help with mogrify numbering

Post by anthony »

I don't think it is posible with mogrify. At least not at this time.
There are proposals however that would make this posible.
But you could try...

Code: Select all

 convert -density 300 doc.pdf  image-%02d.jpg
Or for a slower but better looking result...

Code: Select all

convert -density 1200 doc.pdf  -resize 25% image-%02d.jpg
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: need help with mogrify numbering

Post by fmw42 »

mlanemartin wrote:I am not very experienced using command lines, if a program has a GUI I usually go with that. However, after much Googling and searching through this forum, I have finally come up with a command line that ALMOST does exactly what I want it to. I am trying to batch convert a folder of PDFs to JPGs. What I have come up with is:

mogrify -density 300 -format jpg *.pdf

However the outfile filenames for pages 1 through 9 were: image-0.jpg, image-1.jpg, image-2.jpg, etc.

I wanted the filenames to be: image-00.jpg, image-01.jpg, image-02.jpg, etc.

I found a forum entry on adding a preceding zero using the convert command, which is how I came up with this:

mogrify -density 300 -format -%02d.jpg *.pdf

This is almost perfect except I get an error code:

"mogrify: unable to open image '-%02d.jpg:': Invalid argument.

Despite this error message, the conversion still works, but the resulting filenames are: image.-00.jpg, image.-01.jpg, image.-02.jpg, etc.

I was wondering if there is a way for me to get the filenames without the extra period in there. So:

image.-00.jpg

would instead be:

image-00.jpg

Does anyone have any ideas on how to do this?

Thanks,
Michael

If this is a single pdf file, then there is no need for mogrify. Try the following:

convert image.pdf image-%02d.jpg

For an 9 page pdf, I get image-00.jpg ... image-08.jpg
Last edited by fmw42 on 2008-11-10T17:27:52-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: need help with mogrify numbering

Post by anthony »

If you want to start at 1 rather than 0 add -scene 1

see IM Examples, Writing Multiple Image sequence
http://www.imagemagick.org/Usage/files/#write_seq
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply