Convert from PDF to Image very slow

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
LittleKI
Posts: 32
Joined: 2015-01-11T11:55:29-07:00
Authentication code: 6789

Convert from PDF to Image very slow

Post by LittleKI »

Hi,

i use this command to convert pdf files to image files

Code: Select all

convert -density 600x600 -units pixelsperinch input -background white -alpha background -alpha off -scene 1 -resize 50% -compress jpeg +adjoin output
but thats extremely slow compared to the windows tool PDFXChange Viewer that i used so far. it takes 2 or 3 minutes until the program starts writing the image files. is this normal? is there something wrong with the command?

i'm on ubuntu 16.04, imagemagick version is 6.8.9-9. my system is a gigabyte p55-ud3, intel i5-760 with 8gb ram.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert from PDF to Image very slow

Post by snibgo »

LittleKI wrote:is this normal?
It depends on the size of your PDFs: the number of pages, and the pixels per page. IM converts all the pages to raster, then saves each one. This might need more memory than you have available, so IM uses disk, which is slow.
snibgo's IM pages: im.snibgo.com
LittleKI
Posts: 32
Joined: 2015-01-11T11:55:29-07:00
Authentication code: 6789

Re: Convert from PDF to Image very slow

Post by LittleKI »

It depends on the size of your PDFs: the number of pages, and the pixels per page.

this is clear, but other tools working faster with the same pdf. maybe they are working different? can i change this when using IM?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert from PDF to Image very slow

Post by snibgo »

This is the way ImageMagick works. If your command asks for the entire PDF document, it will all be converted in memory before any images are written.

You can limit the PDF conversion to certain pages, eg with "mydoc.pdf[10-19]". If you have a large PDF, a script can find how many pages there are and have a loop to convert, say, ten pages in each pass.
snibgo's IM pages: im.snibgo.com
Post Reply