Page 1 of 1

newbie - chaining successful commands

Posted: 2011-02-17T04:46:47-07:00
by niconiko
Hello.

Searched the posts, found one similar to what I'm after, but, being still new to IM, that post's solutions were far above my level.

Basically, I want to montage some images, append a header image to each montage, and then convert those montages into a PDF doc. That PDF doc is all I'm really after.

Here's the commands I've gotten to work:

Code: Select all

montage img1.jpg img2.jpg img3.jpg -geometry 150x150+5+5 mix1.jpg
montage img4.jpg img5.jpg img6.jpg -geometry 150x150+5+5 mix2.jpg

convert header.jpg mix1.jpg -append  mix1AndTop.jpg
convert header.jpg mix2.jpg -append  mix2AndTop.jpg

convert mix1AndTop.jpg mix2AndTop.jpg TheEnd.pdf
Thing is though, in actual practice each montage consists of 25 images. So it's taking about 10 seconds to create the PDF. Most likely cause I'm writing to the directory four times to create four files not necessary for download, and probably cause I'm working with disk space rather than memory.

So, how can I combine the commands? And how can I maximize speed?

I've experimented with "-write mpr", but, as I say, too much of IM is still way over my head.

Thank you.

Re: newbie - chaining successful commands

Posted: 2011-02-17T16:55:33-07:00
by anthony
You can save on writes to disks by pipelining using the MIFF (Magick Image File Format)..
http://www.imagemagick.org/Usage/files/#miff

just taking your commands (in a unix shell script)

Code: Select all

  (
    montage img1.jpg img2.jpg img3.jpg -geometry 150x150+5+5 miff:- |
       convert header.jpg  miff:-   -append  miff:-

    montage img4.jpg img5.jpg img6.jpg -geometry 150x150+5+5 miff:- |
        convert header.jpg  miff:-  -append  miff:-

  ) | convert miff:-  TheEnd.pdf
At no time are intermediate saved to DISK, or use the lossy file format JPEG (You should never use JPG for intermediate or non-final images!)

It works as multiple miff:- images are simple images that can be concatenated together in a pipeline to form a multiple image miff:

With more information on the images you are processing It may be posible to remove the second set of convert commands. And with extra shell scripting (looping etc) you may be able to get rid of the montages as well.

At this time montage layout abilities are not available in convert, but I would like to see it made available in convert (with many other layout methods).



Basically I suggest you learn some shell scripting...
BASH How To
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Linux Shell Scripting Tutorial
http://bash.cyberciti.biz/guide/Main_Page
Wizards Boot Camp (Shell)
http://www.linux-mag.com/id/4038/

Or look though my own bookmarks for shell Programming (where teh above came from)
http://www.ict.griffith.edu.au/~anthony ... rogramming