How to create tiles of an image using ImageMagick

crop image-magick

I 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.

Original photo of a dog

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:

Tiled images

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.

© Amy Tabb 2018 - 2023. All rights reserved. The contents of this site reflect my personal perspectives and not those of any other entity.