Ubuntu – Make a grid of images, then rotate and crop it

command lineimage processingimagemagick

So I have a few thousand thumbnails that I want to stitch together in a slightly tilted grid. I figure that's not going to be the most obvious thing in the world to understand so here's an artists impression of the final output, sans images.

enter image description here

I've been using ImageMagick so far to create the 17×8 grid. It's simple enough but here's a version with the rose dummy image that will display to screen:

montage -mode concatenate $(printf 'rose: %.0s' {1..136}) -resize 100x80 -tile 17x out.jpg


But now I want to rotate and crop. If I chuck -rotate 1.5, each image is rotated separately. If I save it and then rotate I compound compression artefacts and lose quality. How do I rotate and crop this grid in the same command?

I'll happily take an alternative to ImageMagick but this has to be command-line as it's going to run on a regular basis on a server.

Best Answer

Well You can pipe things around as BMPs. I think this is as close to lossless as I'm going to get.

montage -mode concatenate $(printf 'rose: %.0s' {1..136}) -resize 100x80 -tile 17x bmp:-\
| convert bmp:- -distort SRT 1.5 -crop 1500x500+100+14 out-rotated.jpg

enter image description here

Though I'll happily take a version that can do this in one command.