Page 1 of 1

montage minimize row/column size?

Posted: 2017-11-03T02:16:28-07:00
by jamadagni
I have nine squares of varying sizes generated by:

Code: Select all

colors=("" 4d2600 590000 730055 2c0059 000080 004d00 638000 ffaa00 323232)
for x in {1..9} ; do
    convert -size $((40 + x * 10))x$((40 + x * 10)) xc:"#${colors[$x]}" $x.png
done
Now I'm trying to montage it so that there is no bordering space between the squares.

As per the method advised under the usage pages (huge thanks to Anthony!) I tried:

Code: Select all

montage ?.png -geometry '1x1+0+0<' out.png
but it is still producing some space between the squares:

Image

I realize it's only because of the difference in size between the tiles. So is there any way to tell montage to not make all tiles the equal size but only size them enough to fit the biggest item in the particular row/column? Or if that is outside the scope of montage then how else using IM can I do that?

Re: montage minimize row/column size?

Posted: 2017-11-03T09:30:05-07:00
by fmw42
I do not think that will work for unequal sizes, since montage will pad to maximum size.

Re: montage minimize row/column size?

Posted: 2017-11-03T09:32:26-07:00
by jamadagni
Thanks for your reply. Is there some way to use convert for this then?

Re: montage minimize row/column size?

Posted: 2017-11-03T09:39:01-07:00
by fmw42
No, I tried append, but you still have space between most of the images. Try this and you will see

Code: Select all

convert -gravity center \
\( 1.png 4.png 7.png -append \) \
\( 2.png 5.png 8.png -append \) \
\( 3.png 6.png 9.png -append \) \
+append result.png
or

Code: Select all

convert -gravity center \
\( 1.png 2.png 3.png +append \) \
\( 4.png 5.png 6.png +append \) \
\( 7.png 8.png 9.png +append \) \
-append result2.png
Perhaps if you showed or explained what you expect, we could try to achieve that.

Re: montage minimize row/column size?

Posted: 2017-11-03T21:17:22-07:00
by jamadagni
I want the size of each tile to be that of the biggest image in its row/column, not the entire grid. See:

Image

Re: montage minimize row/column size?

Posted: 2017-11-03T22:30:03-07:00
by fmw42
Try this. You must get the largest size tile and add 1 to its width and height and use that as below where the black tile is largest and is 130x130.

Code: Select all

convert -background white -gravity center \
\( 1.png 2.png 3.png -extent 131x131 +append -trim +repage \) \
\( 4.png 5.png 6.png -extent 131x131 +append -trim +repage \) \
\( 7.png 8.png 9.png -extent 131x131 +append -trim +repage \) \
-append result3.png

Re: montage minimize row/column size?

Posted: 2017-11-03T22:37:27-07:00
by jamadagni
Thanks for your efforts but sorry, the result is still not what is desired. If you compare to the image I posted above, you can see that in the result of your command the three columns aren't touching each other (in the bottom right which contains the widest elements). Anyhow, if there is no way to automatically do this without manually finding the size of the biggest item, we can just give up.

Re: montage minimize row/column size?

Posted: 2017-11-03T22:42:01-07:00
by fmw42
try this

Code: Select all

convert -background white -gravity center \
\( 1.png 2.png 3.png -extent 131x131 +append -trim +repage \) \
\( 4.png 5.png 6.png -extent 131x131 +append -trim +repage \) \
\( 7.png 8.png 9.png +append \) \
-append result4.png