Using ImageMagick to make a composition of square thumbnails
This isn't a very exciting post, but it took me ages to figure it out, so I wanted to write it down somewhere.
I wanted to use a one line ImageMagick command to:
- Take four pictures
- Resize, centre and crop them to be square thumbnails
- Arrange them in a 2 by 2 grid
Here is the command for ImageMagick on Windows:
convert -size 300x300 xc:transparent
-page 150x150 ( "image1.jpg" -gravity center -resize 150x150^^ -extent 150x150 )
-page 150x150 ( "image2.jpg" -gravity center -resize 150x150^^ -extent 150x150 -repage +0+150 )
-page 150x150 ( "image3.jpg" -gravity center -resize 150x150^^ -extent 150x150 -repage +150+0 )
-page 150x150 ( "image4.jpg" -gravity center -resize 150x150^^ -extent 150x150 -repage +150+150 )
-flatten composition.jpg
This all needs to be on one line. If you're using Linux ^^ should be ^ and brackets need to be escaped with a backslash.
You also need to be using at least ImageMagick version 6.3.8-2.