When given a sequence of images, montage tiles them in "row-first" order. Is there any way to do the sequencing column-first?
E.g. if I have a sequence fig1 to fig9, montage can do this:
1,2,3
4,5,6
7,8,9
... but I want this:
1,4,7
2,5,8
3,6,9
Is there any way to do this without reordering the image sequence at the command line?
Montage column-first tiling?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Montage column-first tiling?
Unfortunately, montage does not seem to support -transpose directly, so one has to use multiple commands as follows:
create 9 numbered test images (tmp1.jpg ... tmp9.jpg):
i=1
while [ $i -le 9 ]; do
convert -size 30x30 xc:white -pointsize 24 -gravity center -annotate 0 "$i" tmp$i.jpg
i=`expr $i + 1`
done
now use convert to transpose them and store in multi-image miff. then montage the transposed miff images. then transpose the montage result back.
convert \
\( tmp1.jpg -transpose \) \( tmp2.jpg -transpose \) \( tmp3.jpg -transpose \) \
\( tmp4.jpg -transpose \) \( tmp5.jpg -transpose \) \( tmp6.jpg -transpose \) \
\( tmp7.jpg -transpose \) \( tmp8.jpg -transpose \) \( tmp9.jpg -transpose \) \
miff:- | montage - -geometry 30x30+0+0 -tile 3x3 miff:- | convert - -transpose tmp_montage.jpg
but you can also do pretty much the same thing with convert and append:
convert \
\( \( tmp1.jpg -transpose \) \( tmp2.jpg -transpose \) \( tmp3.jpg -transpose \) +append \) \
\( \( tmp4.jpg -transpose \) \( tmp5.jpg -transpose \) \( tmp6.jpg -transpose \) +append \) \
\( \( tmp7.jpg -transpose \) \( tmp8.jpg -transpose \) \( tmp9.jpg -transpose \) +append \) \
-append -transpose tmp_append.jpg
Of course the easiest thing is just renumber your list for montage
create 9 numbered test images (tmp1.jpg ... tmp9.jpg):
i=1
while [ $i -le 9 ]; do
convert -size 30x30 xc:white -pointsize 24 -gravity center -annotate 0 "$i" tmp$i.jpg
i=`expr $i + 1`
done
now use convert to transpose them and store in multi-image miff. then montage the transposed miff images. then transpose the montage result back.
convert \
\( tmp1.jpg -transpose \) \( tmp2.jpg -transpose \) \( tmp3.jpg -transpose \) \
\( tmp4.jpg -transpose \) \( tmp5.jpg -transpose \) \( tmp6.jpg -transpose \) \
\( tmp7.jpg -transpose \) \( tmp8.jpg -transpose \) \( tmp9.jpg -transpose \) \
miff:- | montage - -geometry 30x30+0+0 -tile 3x3 miff:- | convert - -transpose tmp_montage.jpg
but you can also do pretty much the same thing with convert and append:
convert \
\( \( tmp1.jpg -transpose \) \( tmp2.jpg -transpose \) \( tmp3.jpg -transpose \) +append \) \
\( \( tmp4.jpg -transpose \) \( tmp5.jpg -transpose \) \( tmp6.jpg -transpose \) +append \) \
\( \( tmp7.jpg -transpose \) \( tmp8.jpg -transpose \) \( tmp9.jpg -transpose \) +append \) \
-append -transpose tmp_append.jpg
Of course the easiest thing is just renumber your list for montage
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Montage column-first tiling?
-transpose will work on all the images in memory so why not... justfmw42 wrote: convert \
\( tmp1.jpg -transpose \) \( tmp2.jpg -transpose \) \( tmp3.jpg -transpose \) \
\( tmp4.jpg -transpose \) \( tmp5.jpg -transpose \) \( tmp6.jpg -transpose \) \
\( tmp7.jpg -transpose \) \( tmp8.jpg -transpose \) \( tmp9.jpg -transpose \) \
miff:- | montage - -geometry 30x30+0+0 -tile 3x3 miff:- | convert - -transpose tmp_montage.jpg
Code: Select all
convert tmp1.jpg tmp2.jpg tmp3.jpg tmp4.jpg tmp5.jpg tmp6.jpg \
tmp7.jpg tmp8.jpg tmp9.jpg -transpose miff:- |\
montage - -geometry 30x30+0+0 -tile 3x3 miff:- | \
convert - -transpose tmp_montage.jpg
If you are appending yourself, there is no need to transpose at all. Just verticallyconvert \
\( \( tmp1.jpg -transpose \) \( tmp2.jpg -transpose \) \( tmp3.jpg -transpose \) +append \) \
\( \( tmp4.jpg -transpose \) \( tmp5.jpg -transpose \) \( tmp6.jpg -transpose \) +append \) \
\( \( tmp7.jpg -transpose \) \( tmp8.jpg -transpose \) \( tmp9.jpg -transpose \) +append \) \
-append -transpose tmp_append.jpg
append first, then horizonatally append!
Code: Select all
convert \( tmp1.jpg tmp2.jpg tmp3.jpg -append \) \
\( tmp4.jpg tmp5.jpg tmp6.jpg -append \) \
\( tmp7.jpg tmp8.jpg tmp9.jpg -append \) \
+append tmp_append.jpg
I also would like to have the montage array handling operator in IM, EG something like -pack array 3x3 to mean append/tile the given image into 3x3 groups. But that is not yet available, unless someone would like to pull the code from montage and move it to the core library.
It could be made smarter too with column/row squeezing, rather than limiting things like montage to just fixed array tile sizes, also the handling 'gravity' justifications and allignments. Their are even other types of packing, such as 'text-like', where images are appended to each row until a given width/height is filled, or attempt to just directly append to best fill N 'equalized columns'.
It would make a nice little project for a new IM library programmer. The key is to try and keep options open to other types of image 'packing' than just simple arrays and tables.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/