Page 1 of 1

Problem with memory PDF to PNG

Posted: 2009-08-24T07:32:18-07:00
by mzstic
Greetings,
maybe it's not bug, i'm quite new with imagemagick and i have no idea, how much memory can conversion from PDF to PNG images take. However i need to convert PDF file(1,3MB, 32 pages) to PNG files in 1000 x something. And i need text in images to be readable. But when i run following command on server, really big amount of memory(over giga) is used and i have to restart server and no PNGs are created... and some way of using less memory exists, because acrobat uses only something over 100MB when converting to png's.

Code: Select all

convert {source}.pdf -resize 1000 -quality 100 {target}.png
Can i do anything to lower memory usage by this script? I'm writing here because i don't have possiblity to try balancing quality/density params, because we can't afford restarting server all the time.
I've posted it here, because i'm not sure it's usual to use such amount of memory... So if it's not memory leak problem u can move this topic to right place.

Re: Problem with memory PDF to PNG

Posted: 2009-08-24T12:16:19-07:00
by magick
Try this command:
  • convert -limit memory 32mb -limit map 64mb -density 144 image.pdf image.png
You can also supersample with this command:
  • convert -limit memory 32mb -limit map 64mb -density 400 image.pdf -resize 25% image.png

Re: Problem with memory PDF to PNG

Posted: 2009-08-26T00:47:13-07:00
by Sarke
I had the same problem, but converting to JPEG and using the -density option (convert -density 300 file.pdf file.jpg). HUGE amounts of memory required. The issue as I see it is that GhostScript is being called to render the PDF in it's entirety and then that ginormous file is then loaded by ImageMagick. Really slow, and with no progress notifications whatsoever it's quite frustrating to not want to kill it.

A much better way to do it IMO would be to do it one page at a time: calling GS for the first page and then rendering it by IM as a JPEG, saving it, and then moving on to the next page.

P.S. Registration was a real hassle; "Authentication Code" AND "Confirmation Code"? And then e-mail activation? Just to submit a bug report? One CAPTCHA is enough for anonymous bug reports. I'm sure most people don't even bother submitting bugs.

Otherwise a great product, thanks and keep it up!

Re: Problem with memory PDF to PNG

Posted: 2009-08-27T09:05:32-07:00
by magick
A much better way to do it IMO would be to do it one page at a time: calling GS for the first page and then rendering it by IM as a JPEG, saving it, and then moving on to the next page.
Try this
convert 'image.pdf[0]' 0.jpg
convert 'image.pdf[1]' 1.jpg
P.S. Registration was a real hassle; "Authentication Code" AND "Confirmation Code"? And then e-mail activation? Just to submit a bug report? One CAPTCHA is enough for anonymous bug reports. I'm sure most people don't even bother submitting bugs.
Both authentication and confirmation are required because there are bots that have broken the authentication code barrier for automatic sign up but so far none have gotten past the confirmation code.