ImageMagick: How to Create a Thumbnail

Updated

Learn how to create a thumbnail from a large image using ImageMagick

ImageMagick: How to Create a Thumbnail

Before we start, make sure you have ImageMagick installed on your computer and your photo ready in a folder. If you don't have it yet, run this command:

brew install imagemagick

First, open your terminal and navigate to the folder that has your photo. To create a thumbnail, run this command:

magick input.jpg -thumbnail 200x200 output.jpg

Just remember to replace input.jpg with your actual filename. The 200x200 is a box, so the longest side ends up at 200 pixels and the image is never stretched. The -thumbnail option is made for shrinking big photos quickly.

If you need an exact square, run this command instead:

magick input.jpg -thumbnail 200x200^ -gravity center -extent 200x200 output.jpg

The ^ makes the image fill the whole box, -gravity center keeps the middle of the photo, and -extent 200x200 crops the extra edges. Even for a huge photo, this finishes almost instantly.

To make sure everything worked, run open output.jpg and check the result.

One more tip: to make thumbnails for a whole folder, run mkdir thumbs and then magick mogrify -path thumbs -thumbnail 200x200 *.jpg. If your phone photos come out sideways, add -auto-orient before -thumbnail.