Blog blurb

This blog is the resting place of my various projects. It's a place to find out about my various commercial and personal projects. Some of them are quite geeky and some of them are more arts based.

RSS Get updates by subscribing to the RSS feed.

ImageMagick Posts

Using ImageMagick to make a composition of square thumbnails

03 July 2009

Four pictures tiled by Image Magick

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.