montage and convert to PDF -- inelegant solution

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
niconiko
Posts: 3
Joined: 2011-02-14T04:41:48-07:00
Authentication code: 8675308

montage and convert to PDF -- inelegant solution

Post by niconiko »

ImageMagick Version: 6.2.8 10/06/10 Q16
pdftk version: 1.41
my ability: newbie

When I first studied this list, my goal was to create a PDF document by combining 25 jpg images (about 5Kb each). A 5x5 bingo card, in other words. Finally, thanks to kind advice here, I got it working.

However, my code is very inelegant (and overly long?). Plus there's a problem. Besides a lengthy run-time (up to 30 seconds?!), the code also seems to hang/crash when the number of montages is increased. You see, I'm not only creating a 5x5 bingo card image, but I'm also combining in these in up to 4-per-page sets.

Here in essence is my code (apologies beforehand for the mental groans it is likely to induce):

Code: Select all

( 
(

montage  [list of 25 jpg images, in random order]  -geometry +5+5 -frame 5 -bordercolor white miff:- 
|  convert [a jpg header] miff:- [a jpg footer] -append miff:-

montage [list of 25 jpg images, in random order]  -geometry +5+5 -frame 5 -bordercolor white miff:- 
|  convert [a jpg header] miff:- [a jpg footer] -append miff:-

[ the above montage string is repeated 7 more times ]

)

| montage miff:- -tile 2x2 -geometry 350x470+10+10 miff:- 

)

| convert miff:- -compress zip ../directory/TheResult.pdf

(Please note that this code, despite of how I've edited it here, does actually work.)

In case it's not clear, the code is doing two montages -- first, an 8-section long montage string of 25 jpg images (organized in random order), and, second, a much shorter "montage -tile 2x2" string of that 8-section montage (so that there's 4 bingo cards on one "page") -- and then converting all that montaging into one pdf doc.

But, there must be a (much!) better way, right?

And, as I say there's a hang/crash problem. Everything's ok when the first montage is 8-sections long. More sections than that, and the script hangs.

By the way. Upgrading the IM version is not an option. I've asked my web-host, and they're dragging their feet on it.

Thank you in advance.
Post Reply