Montage of Combinations and Permutations of .jpg

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
Cardmaker
Posts: 3
Joined: 2017-04-06T07:59:18-07:00
Authentication code: 1151

Montage of Combinations and Permutations of .jpg

Post by Cardmaker »

Hello! I´m absolutely new in ImageMagick. Looking for a -montage solution with twenty two images.
I want get an ouput of 9240 (!) combinations of twenty-two different images without repetition, ordered in 9240 images in a tile 1x3

Permutations without repetition (n=22, r=3) Using Items:
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22

List has 9240 entries.
[1,2,3],[1,2,4],[1,2,5],[1,2,6],[1,2,7],[1,2,8],[1,2,9],[1,2,10],[1,2,11],[1,2,1
2],[1,2,13],[1,2,14],[1,2,15],[1,2,16],[1,2,17],[1,2,18],[1,2,19],[1,2,20],[1,2,
21] [...]

I have no clue how to do this. Some hints? Thank you!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Montage of Combinations and Permutations of .jpg

Post by snibgo »

I would do it like this:

1. Work out what montage command does what you want from three input files.

2. Write a script with three nested loops. The first loops from 1 to 20, the second from the first plus 1 to 21, the third loops from the second plus 1 to 22.

3. Within the third loop, call the montage with the required three filenames.

Obviously, the details will depend on the version of IM you use and your script language.
snibgo's IM pages: im.snibgo.com
Cardmaker
Posts: 3
Joined: 2017-04-06T07:59:18-07:00
Authentication code: 1151

Re: Montage of Combinations and Permutations of .jpg

Post by Cardmaker »

Thank you! :) A very good hint.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage of Combinations and Permutations of .jpg

Post by fmw42 »

I have moved this post to the Users forum, since it seems directly related to IM commands
Cardmaker
Posts: 3
Joined: 2017-04-06T07:59:18-07:00
Authentication code: 1151

Re: Montage of Combinations and Permutations of .jpg

Post by Cardmaker »

Done!
I just write this line 9240 times, one for a permutation

magick montage -background #FF0000 01.jpg 02.jpg 03.jpg -mode Concatenate -tile x1 montage#.jpg

Thanks for the help!
Post Reply