Page 1 of 1

Simple montage bash script

Posted: 2012-08-06T17:38:03-07:00
by Lepy
I would like help with creating a simple montage script on one of my Ubuntu machines.

I have a folder of files where the filenames are FILENAMEf.jpg and FILENAMEb.jpg and want each set of files ending in f and b to be combined into one picture using montage.

I can successfully use montage to combine the two pictures by hand using the command: "montage -tile 2x2 -geometry +0+0 FILENAMEf.jpg FILENAMEb.jpg FILENAME.jpg". However, manual input is cumbersome, so I would like to automate this process through a bash script. If possible, it would also be nice to have two scripts, one that keeps the original files and one that deletes them.

Can any ImageMagick wizards help me out?

Re: Simple montage bash script

Posted: 2012-08-06T18:25:20-07:00
by fmw42
Most of what you need is just unix shell filtering of file names from the ls command. You will need to write a loop (for or while) and process pairs of name. But first you need to filter them into pairs by name. That is mostly a sorting issue, I presume. If you have matching names, you can make two lists, one ending in b and one ending in f, each sorted alphabetically. Then just make the lists into arrays and loop over the array index.

But just a note. You do not need to use montage unless you want borders and/or labels. You can just use +append to put two images together. See http://www.imagemagick.org/script/comma ... 7g5#append and http://www.imagemagick.org/Usage/layers/#append