Page 1 of 1

convert better performance

Posted: 2009-09-17T05:56:41-07:00
by tudorizer
Hello guys,

I'm trying to see how to convert a .pdf to individual .jpg page as fast as possible.

I've tried:

convert -verbose -adaptive-resize 1500x1500 -colorspace RGB -antialias -density 150 ects.pdf ects.jpg

and I got pretty good results (25 seconds, on my benchmark .pdf file). All the options there give a satisfying resulting .jpg (readable even when zooming).

Can I somehow get this done in less than 25 secods ?

I've tried using ghostscript directly to split the image and mogrify for resize, but added up, the process is slower than "convert".

2nd problem is that "convert" eats many resources. I tried with a 300page .pdf and CPU and RAM usage went crazy (100%) and it froze.

Thanks.

Re: convert better performance

Posted: 2009-09-17T06:00:54-07:00
by magick
Bypass ImageMagick and use Ghostscript directly from the command line.

Re: convert better performance

Posted: 2009-09-17T06:57:59-07:00
by tudorizer
magick wrote:Bypass ImageMagick and use Ghostscript directly from the command line.
I tried that, but that's only good for splitting the pdf. The resulting .jpg need to be resized and I don't see anything like that into GS docs.

Re: convert better performance

Posted: 2009-09-17T10:00:21-07:00
by fmw42
convert -verbose -adaptive-resize 1500x1500 -colorspace RGB -antialias -density 150 ects.pdf ects.jpg
You might get faster results as follows:

1) if you are on Q16 IM, try compiling for Q8

2) change -adaptive-resize to simply -filter XXX -resize or better -sample

3) try a different -quality setting for the jpg (don't know if 100 would be faster than a low value), the default is 85 I believe, so it has to do some compression. don't know if it is faster for a higher or lower compression. A low value will compress more and take time, but will write out a smaller image so faster. So don't know if compression is more time consuming than writing a larger file.

4) not sure if -antialias has any benefit in this conversion

5) syntax may be more correct as

convert -verbose -density 150 -colorspace RGB -antialias ects.pdf -adaptive-resize 1500x1500 ects.jpg

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

Don't know the effects of resulting quality! You will have to test variations to see.

Re: convert better performance

Posted: 2009-09-18T00:09:33-07:00
by anthony
You can always use GS, and then feed it results into IM for resizing.

That will still be faster!


IM does a lot of file copying for security reasons when dealing with delegates such as GS, that is just the way it is. Using GS directly bypasses that copying, especially if you can pipeline the output of GS into IM so it does not have moreDisk IO limitations.