PDF conversion fails with 156 pages, but works with 30 pages

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
soulrebel

PDF conversion fails with 156 pages, but works with 30 pages

Post by soulrebel »

Hello,

I want to convert a PDF file with 156 pages (filesize: 46 mb) to JPGs. If I split up the PDF to 5 PDF files with each around 30 pages it works fine with every PDF, but not using the complete PDF. A 30 pages PDF takes aorund 10 seconds to be converted, the script for the complete PDF breaks after 7 seconds without having converted any JPG. I am using the command: exec("convert -colorspace rgb input.pdf output.jpg"); in a PHP file. The script per-process memory limit of php5 is 128 mb and the run time is a maximum of 10 minutes. Is there a limitation concerning filesizes or page amount?

Any help is much appreciated.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: PDF conversion fails with 156 pages, but works with 30 pages

Post by magick »

Try this command:
  • convert -limit memory 1mb -limit map 1mb -colorspace rgb input.pdf output.jpg
If the command fails in PHP, try it from the command line.
soulrebel

Re: PDF conversion fails with 156 pages, but works with 30 pages

Post by soulrebel »

Thank you for the quick answer!

Functioned well using the command line, but not using PHP. What can be the reason as there is no error message?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: PDF conversion fails with 156 pages, but works with 30 pages

Post by magick »

ImageMagick uses the Ghostscript delegate library to render PDF. Its possible Ghostscript is exceeding the stack / memory limits imposed by PHP. You can increase these limits in your PHP configuration file. Add -debug all to your command line to find out where ImageMagick is exiting prematurely. If its in the delegate processing code, its most likely Ghostscript that is failing.
soulrebel

Re: PDF conversion fails with 156 pages, but works with 30 pages

Post by soulrebel »

PHP has a per process limit of 128 mb, so it shouldn't be a memory limit. Is there a possibility to have a debug report using PHP? Used -debug all in the command line, but there the PDF conversion is functioning, so I don't know if the debug report from the command line can help to understand the PHP execution of the same command?
Post Reply