Create images for first page of several pdf files

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
Arnaud04
Posts: 1
Joined: 2011-12-20T01:10:08-07:00
Authentication code: 8675308

Create images for first page of several pdf files

Post by Arnaud04 »

Hello,

I need to create images for the first page of several pdf files.

I'm able to do it for one pdf with the following command :

Code: Select all

convert -density 708x708 -resize 500 source.pdf[0] destination.png
But I can't find how to deal with a lot of pdf. I've tried

Code: Select all

convert -density 708x708 -resize 500 -format png *.pdf[0]
but it doesn't work.

How could I specify the [0] option (for first page only) for all files ?

Thank you for your help.

Arnaud
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create images for first page of several pdf files

Post by fmw42 »

use mogrify in place of convert. mogrify works on all files in a given directory and can writes them to a new directory with the same name

see
http://www.imagemagick.org/Usage/basics/#mogrify

mogrify -density 708x708 -resize 500 -format png *.pdf[0]

I am not sure whether it will handle the frame number [0], but it is worth trying.
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: Create images for first page of several pdf files

Post by whugemann »

You should mention your OS. Under Windows the command would be something like (not tested):

For %i IN (*.pdf) DO convert %i[0] %~ni.jpg

Use double percent signs when using the command in a batch file (which must then be located in the same directory as the PDFs).
Wolfgang Hugemann
Post Reply