Page 1 of 1

Montage column-first tiling?

Posted: 2009-02-27T02:21:56-07:00
by int19h
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?

Re: Montage column-first tiling?

Posted: 2009-02-27T11:22:49-07:00
by fmw42
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

Re: Montage column-first tiling?

Posted: 2009-02-28T06:55:37-07:00
by int19h
Thanks - renumbering it is!

Re: Montage column-first tiling?

Posted: 2009-03-01T20:19:49-07:00
by anthony
fmw42 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
-transpose will work on all the images in memory so why not... just

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
However there is no reason why montage can't use -transpose, so request it to be added to montage. That however will not help re-transpose the output back again.
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
If you are appending yourself, there is no need to transpose at all. Just vertically
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
You can also fake the framing and labeling methods that montage uses, not easilly (though it should be) but it should be.

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.