Page 1 of 1

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

Posted: 2008-07-19T15:43:03-07:00
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.

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

Posted: 2008-07-19T15:59:14-07:00
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.

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

Posted: 2008-07-19T16:12:18-07:00
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?

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

Posted: 2008-07-19T17:00:05-07:00
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.

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

Posted: 2008-07-20T11:24:27-07:00
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?