up vote 0 down vote favorite
share [g+] share [fb]

I often use ImageMagick's convert for *->PNG conversion, but when PDF has more than 50 pages — convert eats more that 3 Gib (!!!) of memory. I guess it first loads everything.

That's unacceptable. It should read PDF page by page, why the heck all of them at once!

Maybe there's a way to tune it somehow? Or any good alternatives?

link|improve this question

concerning "close(1)" I see right there: convert is also often used in web applications, including PDF convertion. – o_O Tync Dec 25 '09 at 17:52
feedback

2 Answers

up vote 3 down vote accepted

Have you tried cache?

From the man page

-cache threshold

      megabytes of memory available to the pixel cache.

      Image pixels are stored in memory until 80 megabytes of
      memory have been consumed.  Subsequent pixel operations

      are cached on disk.  Operations to memory are  significantly 
      faster but if your computer does not have a sufficient 
      amount of free memory you may  want  to  adjust
      this threshold value.
link|improve this answer
Is it an option for convert? I have only "-limit type value pixel cache resource limit". Plus your quote says "80Mb is the default", but my convert eats all RAM :) – o_O Tync Dec 25 '09 at 18:30
80Mb may be the default if you just add the -cache without a value following it. – Shikoru Dec 25 '09 at 18:33
Hmm, my IMagick has only "-limit memory 64" to limit its memory to 64MB. It works, thanks anyway! :) – o_O Tync Dec 25 '09 at 18:45
Found: " -cache <threshold> (This option has been replaced by the -limit option)" – o_O Tync Dec 25 '09 at 18:48
feedback

convert -limit memory 64 -limit map 128 original.djvu newfile.pdf

My main drive has limited space, so I prepend a variable

env MAGICK_TMPDIR=/host/Temp convert -limit memory 64 -limit map 128 original.djvu newfile.pdf

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.