0xbad1d3a5
0xbad1d3a5

Reputation: 126

Tile images of different aspect ratios using ImageMagick without gaps

I want to be able to tile together images of different aspect ratios in a way that looks good and avoids as much whitespace between the images as possible.

What I've done so far is rename all the images using a script that changes the image name to the aspect ratio, which makes ImageMagick tile the narrowest images first:

enter image description here

for i in *.jpg;
    do mv "$i" $(printf '%.4f' $(echo "scale=4;" $(identify -format "%w" "$i") "/" $(identify -format "%h" "$i") | bc))"$i";
done

Then I run ImageMagick:

montage -mode concatenate -tile 6x -geometry 250x+10+20 -background black *.jpg out.jpg

Which gives me something like this:

enter image description here

Unfortunately, I want something like this, where there isn't as much vertical space between the images with the smaller aspect ratios and bigger ones:

enter image description here

Anyone have any ideas?

Upvotes: 1

Views: 322

Answers (0)

Related Questions