May 15, 2014 at 8:14 PM by Dr. Drang
Pinboard Popular is currently featuring a listicle written by Mitchell Cohen entitled “Eight Terminal Utilities Every OS X Command Line User Should Know.” It’s a decent enough list, but it’s missing one of my favorites,
Sips is the “scriptable image processing system,” and I’ve written about it here a few times. I used it today to solve a big problem in no time at all.
I had a folder of a few hundred photographs that I wanted to share with a client. Sending him a Dropbox link was the obvious solution, but uploading that many photos, each of which is 5-10 MB, would take too long, and he wouldn’t be interested in the details of the full resolution photos anyway. The obvious solution was to downsample the photos to a more reasonable size before uploading; I figured 1024 pixels in the long direction would be just right.
I’m sure there are plenty of GUI utilities that could do the resizing, but I can’t imagine any of them being easier to use than
sips. I copied the folder of photos, opened a Terminal window that was
cd’d to that directory1, and ran
sips -Z 1024 *
Sips chugged away at the files, resizing them in place, and spitting lots of info out to the Terminal as it did so. (Traditional Unix utilities are laconic; most of Apple’s command line utilities are anything but.
Sips is positively garrulous.) I soon had over four hundred modestly sized JPEGs taking up about 80 MB in total. The upload to Dropbox was quick.
The key is the
-Z option. As the man page says, this option, which has a long equivalent of
Resample image so height and width aren’t greater than specified size.
Sips has options for resampling to a specified height (
--resampleHeight) and to a specified width (
--resampleWidth), but I find myself using
-Z more often than either of those.
Sips doesn’t have to resize in place. There’s an option for making a new file, but I seldom use it because it’s just faster to make a copy and resize that in place.