Batch Resize a Group of Pictures from the Command Line with sips

Nov 25, 2012 - 5 Comments

Batch resize group of pictures with sips

Though most Mac users will likely prefer to use Preview to batch resize images because of the ease of use, advanced users often like to go with the command line for repetitive tasks. We’ve discussed sips before as a way to resize, rotate, and flip images, but if sips is combined with wildcards it can also function as a quick way to batch resize a group of photos.

Launch Terminal from the /Application/Utilities/ folder and use the following syntax:

sips -Z (max height in pixels) /path/to/images/*.(image file extension)

For example, to resize a collection of jpg pictures to each have a max height of 620, located in the desktop folder “ResizeMe”:

sips -Z 620 ~/Desktop/ResizeMe/*.jpg

The -Z flag instructs sips to retain the images original aspect ratio while maintaining a maximum height of 620, but you can also specify exact height and width by using a lowercase -z flag instead like so:

sips -z 620 840 *.jpg

The height in pixels is first, followed by the width in pixels.

If the command line doesn’t fit well into a workflow, another great option is to batch resize images with an Automator script, which has the added benefit of becoming a self-contained application allowing for standard Finder interactions like drag and drop.

This handy reminder about sips comes to us from Lifehacker

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Command Line, Mac OS X, Tips & Tricks

5 Comments

» Comments RSS Feed

  1. Dante says:

    Good tip, but I would add another step that is making a copy of the pictures that you want to resize. That way you can still have the original dimension pictures available too.

  2. pr10n says:

    I’ve been using SIPS for goodness knows how long. I like adding a little spotlight love to it so I can recursively hunt down images that are larger than my target size.

    mdfind -0 -onlyin . “kMDItemPixelHeight > 620 || kMDItemPixelWidth > 620″ | xargs -0 sips -Z 620

  3. nlapjr says:

    Thanks! Great help!
    Maybe you can feature more Automator tips and tricks.
    That app has a lot of potential but is not covered much.

  4. Lauri Ranta says:

    sips (and Preview and Automator) make images fairly blurry though. ImageMagick allows choosing from different interpolation filters and adding sharpening manually. It also has more resizing and cropping options.

    This would make images 50% smaller and convert them to JPG:

    mogrify -filter lanczos2 -resize 50% -format jpg -quality 92 -path ~/Desktop/ *.png

  5. diselsamm says:

    Another possible solution is to use Gimp, an excellent free software.

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates