Batch resizing images from the command line on a Mac

If you need to quickly resize a bunch of images on a Mac, you don't need to open Photoshop. There's a simple way to do it from the command line, by using the sips command. This is the basic syntax:

Resize a single image

By way of example, to resize a single image to a maximum of 800px (either width or height), you'd use the following. It's important to note that this will replace the existing image, so make a copy if you want to keep the original.

$ sips -Z 800 image.jpg

Resize multiple images

Where sips really comes into it's own is for folders of images. To resize multiple images just use a wildcard with the file extension (.jpg in this case). The example below will blast through all the images in folderName, resizing them to 1200px in a flash.

$ sips -Z 1200 folderName/*.jpg

Resize multiple images with format conversion

Converting the format of the image along with resizing is best done through imagemagick's mogrify command. First, ensure you have imagemagick installed:

$ brew install imagemagick

Then run mogrify . The following command will resize all images from inputFolder to 800px wide jpgs in outputFolder.

$ mogrify -resize 800 -path 'outputFolder/' "inputFolder/*.jpg"

The full list of mogrify options is available here.

James Chambers
Good morning. I'm James.

I send a twice-monthly newsletter about building indie software products. It's called Build Notes, and you can sign up below.

© 2014-2020 James Chambers