How to create tiles of an image using ImageMagick
21 Jun 2023I wanted to slice one image into a bunch of smaller images – tiles – and of course did not want to do this manually. That means … ImageMagick!
I’m going to work through one example, using the photo below, named PupPhoto.jpg
. The ImageMagick documentation on crop has more options than I use here.
Figure 1: Photo of cute dog. I may be biased.
The size of this image is 2037 x 1356 pixels. First, I crop the image to a size that is a multiple of 200.
convert PupPhoto.jpg -crop 2000x1200+0+0 cropped.jpg
Then, I chop that cropped image into the tiles:
convert cropped.jpg -crop 200x200 PupPhoto-tile-%02d.jpg
The tiles, original, and cropped images in a directory looks like this:
Figure 2. The original, cropped, and tiled images in a directory.
Do you want to assemble some images into a montage? There’s another TIL for that: Amy Tabb – How to create a montage in ImageMagick.