Page 1 of 1
Convert PDF to JPG with +append
Posted: 2012-02-24T03:55:44-07:00
by loru88
Hello everyone
I'm new to imagemagick, and I need a little help.
I have a pdf, I want to convert it in jpg but I need to have a jpg file for every two consecutive pages
I have used this command to convert just two pages in a single jpg file with the page side by side
Code: Select all
convert pdf_file.pdf[0-1] -colorspace rgb -density 300 +append two_pages.jpg
but what if I want to automate this operation for every two consecutive pages?
there is some kind of option to do this task? I tried with -tile 2x1 option but it doesn't work
if it isn't possibile I have to write my own script to do this task
Re: Convert PDF to JPG with +append
Posted: 2012-02-24T10:52:13-07:00
by fmw42
I think you have to write a short script to loop over your pages in the file and do them two at a time. I don't think there is a way to provide automatic skips in pages in IM over a series of pages.
Re: Convert PDF to JPG with +append
Posted: 2012-02-24T18:01:17-07:00
by loru88
I made by my self, the solution was easy.
the command to do this is is a simple -montage with the -convert option
Code: Select all
montage -density 300 album.pdf -mode Concatenate -tile 2x1 -quality 80 -resize 800 two_page.jpg
in this way each jpg is a pair of consecutive pdf's pages and they are very high quality and not much heavy
now I have another question: the first page in the pdf is the cover, so i want to exclude the first page and do that command on the other pages.
this command works, I found the number of pdf pages using
identity command
Code: Select all
pdfpage=`identify -format %p -density 12 album.pdf`
montage -density 300 album.pdf[1-$pdfpage] -mode Concatenate -tile 2x1 -quality 80 -resize 800 test_%04d.jpg
but It is slow, and not elegant...
Someone know some kind of solution to exclude the first page only?
Is there a special command in Imagemagick or in the bash scripting language or some special wildcard?
Re: Convert PDF to JPG with +append
Posted: 2012-02-27T20:41:20-07:00
by anthony
That would be very slow as the PDF is converted twice.
Solution just read them all in. and delete the first (zeroth) image
Code: Select all
montage -density 300 album.pdf -delete 0 ....
Re: Convert PDF to JPG with +append
Posted: 2012-02-28T01:47:26-07:00
by loru88
Thanks for the reply, but it doesn't work, it said there is an error:
montage: unrecognized option `-delete' @ error/montage.c/MontageImageCommand/867.
in fact the -delete option isn't listed in the montage option summary (
http://www.imagemagick.org/script/montage.php)
I have tried also this command for exclude the first page with wildcard
Code: Select all
-density 300 album.pdf[^0] -mode Concatenate -tile 2x1 -quality 80 -resize 800 two_page.jpg
and it partially work: it return one jpg for each two pages (side by side) except the first
but all the jpg are just grey images...
maybe this is a bug or I suppose the wildcard can't be used in this way...
For me is good also to have the first page of the pdf side by side with a blank page when it is converted in jpg, like a fill image
it could be possibile to do this?
Re: Convert PDF to JPG with +append
Posted: 2012-02-28T16:54:14-07:00
by anthony
Montage should allow the use of
-delete.
If it doesn't then, it is a bug (or your IM is very very very old).
Montage should work exactly like convert, with just a few options (like -geometry and -frame) substituted.
However it is actually missing quite a few options, which have been added as people request them.
I have now added all the image list options (-delete, -insert, -reverse, -swap) that were missing from "montage" for the next release of IMv6 (when that happens). Version 6.7.5-8
ASIDE: I am currently working on IMv7 Shell/Script API, and such missing options between the various commands, other than the special exceptions for that specific command will not be possible!