Page 1 of 1

convert a series of png's to one pdf -to many?

Posted: 2013-09-13T07:10:39-07:00
by silversun
I am annotating a series of png's - 10 images right now - with text and then I am converting them to a single pdf.

the annotation which works fine produces a png with an average size of 200k:

Code: Select all

convert 001.png -pointsize 42 -gravity NorthWest -annotate +2176.92307692+272.769230769 '13' -annotate +1469.23076923+1053.53846154 'round rock' -annotate +319.230769231+953.538461538 '1400 wroxton way' -annotate +2065.38461538+1049.69230769 '78664' -annotate +1980.76923077+2199.69230769 '75000.00' img_tmp/001.png
Then I take all the new images and convert them to a pdf. The problem is that if I have more than 5 images or over 1.3meg it seems the resulting pdf has a header of PNG (not really a pdf document) and only the first page. It is not actually a pdf file. 5 or less images and the resulting pdf is viewable with all pages.

my code for pdf conversion.

Code: Select all

convert -density 150 img_tmp/001.png img_tmp/002.png img_tmp/003.png img_tmp/004.png img_tmp/005.png img_tmp/006.png img_tmp/007.png img_tmp/008.png img_tmp/009.png img_tmp/010.png img_tmp/offer.pdf
I have made sure that the php memory limit and time limit are sufficient. Does anyone know why Imagick can not convert more than 6 images to one pdf?

Re: convert a series of png's to one pdf -to many?

Posted: 2013-09-13T07:57:54-07:00
by snibgo
ImageMagick can convert any number of PNG files into a single PDF.

I know nothing about PHP and IMagick. You may be hitting a limit on command length.

Re: convert a series of png's to one pdf -to many?

Posted: 2013-09-13T10:01:33-07:00
by fmw42
Process it outside of PHP in a terminal window and see if that fails. If not, then it is PHP limitations. If it fails, then you may be running out of memory or perhaps your tmp directory is limited.

I do not know if this is relevant, but see http://www.imagemagick.org/Usage/files/#massive

Also see
http://www.imagemagick.org/script/resou ... nvironment


Note also that properly the -density in this command should be after reading all the input images and before your pdf output. But it may still work as you have it.

Re: convert a series of png's to one pdf -to many?

Posted: 2013-09-13T10:28:19-07:00
by silversun
Thanks Guys!!

I found the error.

one of the images is a small picture of a check. So it is not a full page with white space like the rest of the png's which are copies of an original pdf doc.

If i remove this image from the list everything works. try to convert the check image to pdf on its own and it fails.

Any ideas on this?

Re: convert a series of png's to one pdf -to many?

Posted: 2013-09-13T10:31:34-07:00
by snibgo
What error messages do you get?

Try the following:
convert cheque.png x.jpg
identify -verbose cheque.png
identify cheque.png

Re: convert a series of png's to one pdf -to many?

Posted: 2013-09-13T10:43:49-07:00
by silversun
if i try that on the (007.png)check.png it returns empty. The $out array is empty and the $ret1 is set (error). The new007.jpg is not created.

i tested on a standard page and it returns a lot of info.

Code: Select all

        exec('convert 5231c415edcc9/007.png new007.jpg');
        exec('identify -verbose 5231c415edcc9/007.png', $out, $ret);
        exec('identify 5231c415edcc9/007.png',$out2, $ret2);
;

These PNG's are coming from a PDF file. Each page is converted to PNG with ghostscript. So if one of the pages is nothing more than an image of a check should i be doing something in that process?

Re: convert a series of png's to one pdf -to many?

Posted: 2013-09-13T10:51:55-07:00
by snibgo
What happens when you run those commands from the command line?

Re: convert a series of png's to one pdf -to many?

Posted: 2013-09-13T13:19:34-07:00
by silversun
i do not have shell access :(

Re: convert a series of png's to one pdf -to many?

Posted: 2013-09-13T13:31:57-07:00
by snibgo
Can you copy the problem file to somewhere like Dropbox and post the URL here?

Otherwise, I can only suggest that you try to "identify" each file before using it. If that fails, throw an error.

Re: convert a series of png's to one pdf -to many?

Posted: 2013-09-13T13:32:51-07:00
by fmw42
Post a link to the bad image so we can examine it. You can upload to any free image hosting server and then put a like to it here.