Luis Morales
Luis Morales

Reputation: 126

How to set the order of a ImageMagick montage

I want to order images not in the natural order (left-right-top-bottom) but in the order top-bottom-left-right. So when i have 8 images i want to have the first 4 in the first column and the images 5-8 in the second column.

1 5
2 6
3 7
4 8

But as in the montage usage guide i get:

1 2
3 4
5 6
7 8

I'm using montage -mode concatenate -tile 2x4 input_*.png output.png

I found a similar question here, but the answer to use -scene doesn't affect the result.

Another way would be to do it in two steps, so first create just the rows with montage -mode concatenate -tile 1x{nrOfRows} input_*.png output.png and after that create the columns with the output of the previous command with montage -mode concatenate -tile {nrOfColumns}x1 output*.png result.png.

The problem is that currently i have 1024 images and want them in 64x16 and so the output.png's become output_0.png to output_63.png. So when i run the second command the order is:

output_0.png
output_1.png
output_10.png
...
output_19.png
output_2.png
output_20.png
....

and so some rows are not correct.

Every hint is appreciated!

(Currently i test this via the cmd on a Windows machine but later want to have it in PHP on Linux machine)

Upvotes: 5

Views: 1914

Answers (1)

phil294
phil294

Reputation: 10912

To summarize:

rows=10
columns=20
  • concatenate images in a left to right, top to bottom order:
    montage -mode concatenate -tile ${columns}x${rows} input*.jpg output.jpg
    
  • concatenate images in a top to bottom, left to right order:
    montage -mode concatenate -tile 1x${rows} input*.jpg _tmp_%04d.jpg
    montage -mode concatenate -tile ${columns}x1 _tmp_*.jpg output.jpg
    rm _tmp_*.jpg
    

Upvotes: 0

Related Questions