Immediately Resize, Rotate, and Flip Images via Command Line with sips
You can resize, rotate, or flip any image file via the Mac’s Terminal using the powerful command line sips tool. Manipulating images with sips is practically instantaneous, and if you need to quickly resize, rotate, or flip an image file and want to stay within the command line, it can definitely beat firing up a GUI application like Preview to perform the same image modification tasks. Note that sips changes the image file instantly, there is no confirmation required.
Let’s get started and learn how to quickly make some image edits and modifications with sips.
Resizing an Image with sips from Terminal
To instantly resize any image file with sips, you just need to use the following command syntax:
sips -z 600 800 test.jpg
The format for the sips -z flag is height first then width, so despite the command appearing dimensionally backwards to many computer users, the above command would resize an image to be 800 pixels wide by 600 high. You can adjust this as appropriate, either staying within the proportions as already set by the image, or even resizing a picture out of the usual restraints and going to a completely new size, just remember the command syntax and format for resizing is:
sips -z height width [file]
Rotating Images from sips at the Terminal
By default, sips rotates clockwise so you just need to specify the degrees you want an image rotated, like so:
sips -r 90 image.jpg
The file will immediately be rotated 90 degrees clockwise. Changing the degrees and the -r flag will set the rotation as appropriate, for example this would flip the image file as directed a total of 270°:
sips -r 270 image.jpg
To review, the command syntax for rotation is:
sips -r degree [file]
Flip an Image with sips in the Terminal
Using sips, you can also flip any image vertically or horizontally from the command line, here’s an example:
sips -f horizontal image.jpg
This will instantly flip image.jpg horizontally, you can just as easily flip the image vertically by replacing horizontal with vertical like so:
sips -f vertical image.jpg
For flipping images, the command syntax to remember is:
sips -f orientation [file]
Note that we used JPG files for the purpose of these example command syntax, but in fact you can use the sips command on almost any image file format, whether it’s PNG, TIFF, JPEG, GIF, PDF, PICT, and many others. Speaking of file formats, sips can also convert image files to new formats with a command as well as perform command line based batch resizing. Overall, sips is incredibly powerful, and if you’re a command line user and need to modify images, you’ll find plenty of usage for it. Check out all of our sips tips here.