convert better performance

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
tudorizer

convert better performance

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: convert better performance

Post by magick »

Bypass ImageMagick and use Ghostscript directly from the command line.
tudorizer

Re: convert better performance

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert better performance

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

Re: convert better performance

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply