Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a large number of tiles, with the following naming convention:

A-x-y.jpg

where

0<=x<=16 &
0<=y<=14

Now I know that we can use the Montage tool in ImageMagick, to merge them into one whole image.

Ideally I could have used the following command line:

montage *.jpg -geometry +0+0 -tile 17x15 all.jpg

but my files are such that A-0-0.jpg is directly above A-0-1.jpg, which is above A-0-2.jpg and A-1-0.jpg is to the right of A-0-0.jpg.

So when I use the above command the order is wrong. I have a text file with the correct order. Can I use the text file as an input to montage. If so, how do I do it?

share|improve this question

2 Answers 2

In the newer versions of ImagMagick (i.e >v6.5.2-1) @ operator can be used like this:

montage @list.txt -geometry +0+0 -tile 17x15 all.jpg
share|improve this answer

It looks like montage does not support a "file with filenames" argument.

Edit: @Devdatta found the correct syntax (see also here): @filenames.txt. So, the method below should only be necessary for very old versions of the ImageMagick tools.


But if you are using Linux or a Unix-like system, you can replace the filename argument(s) with the output of a command. This way, you can use your file with the ordered filenames:

montage `cat filenames.txt` -geometry +0+0 -tile 17x15 all.jpg

(Please note the backticks around the cat command.)

Line breaks between filenames in filename.txt do no harm to the command invocation. And you may even use wildcards in filename.txt, as command substitution precedes filename expansion.

Of course, you could also rename the source files beforehand to yield the order wanted.

share|improve this answer
    
Beware, this breaks if one of the file names contains whitespace of any sort. –  slhck Jul 15 '13 at 16:02
    
PS: Under Windows Powershell, the following syntax could work (untested): montage $(cat filenames.txt) -geometry +0+0 -tile 17x15 all.jpg –  Dubu Jul 15 '13 at 16:04
    
This is also possible on POSIX. In fact, preferred over the backticks. –  slhck Jul 15 '13 at 16:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.