I have a lot of images, different sizes and aspect ratios. Is it possible to make a montage of them? I mean to optimally arrange them in rows after I set a common height for the images which build up a common row. Images aspect ratios aren't allowed to modify of course, and none of the images are allowed to omit from the final montage nor duplication.
The height of picture rows in the montage usually aren't equal, but their values should be kept in a minimal range (in statistical sense) or in other words: standard deviation from the mean value of the row heights must be minimized.
Desired width and height of the montage are given (a.)
Or the width and an allowed ratio range (or equivalently height range) is given (b.), for example width must be 1024 pixel, height must be so that w/h < 0.9 and w/h > 0.8
1.) Images must be packed in the montage in their initial fixed order. In this case one must find the images after what a new image row should be started in the montage (easy).
2.) Order of images is allowed to be altered. In this case one must find a permutation which lead to a minimalization of the standard deviation of the final row heights when each image is packed into the montage (hard).
For example:
To resize an image to specific dimensions, use the convert command with an input file, the -resize parameter, your preferred dimensions, and an output filename: convert original. png -resize 100x100 new.
To create an exact aspect ratio, divide the height by the width. For example: 2:3 aspect ratio: 3 ÷ 2 = 1.5, so you'd drag the slider to 150. 3:2 aspect ratio: 2 ÷ 3 = .
The montage command has an option called "-geometry" which helps you to set the thumbnail size and the space between each image. The default -geometry setting is '120x120>+4+3'. Meaning - It will produce 120×120 thumbnails with 4 pixels on the left and right of each image and 3 pixels below.
I'm not sure I understand your question correctly.
Here is what I make of it. Assuming you have 8 different images of different sizes. For demo purposes, I'll let ImageMagick create these as 8 different color patches:
convert -size 90x90 xc:yellow y.png
convert -size 120x120 xc:red r.png
convert -size 60x210 xc:green g.png
convert -size 150x180 xc:blue b.png
convert -size 30x60 xc:cyan c.png
convert -size 150x90 xc:magenta m.png
convert -size 90x120 xc:gray Gr.png
convert -size 120x90 xc:black K.png
You can montage these patches in many different ways:
convert \( y.png r.png g.png b.png +append \) \
\( c.png m.png Gr.png K.png +append \) \
-append \
-mattecolor lightblue \
-frame 1x1 \
montage0.png
This command does not scale the different patches. It places them in 2 rows a 4 patches and montages them in their original sizes. The white spaces is where the patches do not "fit":
convert \( y.png r.png g.png b.png -resize x60 +append \) \
\( c.png m.png Gr.png K.png -resize x60 +append \) \
-append \
-mattecolor lightblue \
-frame 1x1 \
montage1.png
This command scales all different patches to a common height of 60 pixels (preserving their respective aspect ratios) and places them in 2 rows a 4 patches:
convert \( y.png r.png g.png b.png -resize 60x +append \) \
\( c.png m.png Gr.png K.png -resize 60x +append \) \
-append \
-mattecolor lightblue \
-frame 1x1 \
montage2.png
This command scales all different patches to a common width of 60 pixels (preserving their respective aspect ratios) and places them in 2 rows a 4 patches:
convert \( y.png r.png g.png b.png -resize 60x80\! +append \) \
\( c.png m.png Gr.png K.png -resize 60x80\! +append \) \
-append \
-mattecolor lightblue \
-frame 1x1 \
montage3.png
This command scales all different patches to dimensions of 60x80 pixels (overriding their original aspect ratios) and places them in 2 rows a 4 patches:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With