Immediately Resize, Rotate, and Flip Images via Command Line with sips

Jul 13, 2010 - 6 Comments

sips command line image modification tool 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.

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: Bill Ellis in Command Line, Tips & Tricks

6 Comments

» Comments RSS Feed

  1. matt says:

    Hey,
    Do you know if there is a way to specify JPEG quality with sips? With the orientation example this shouldn’t matter as it is possible to change the orientation of a JPEG (I think in Exif rather than JFIF JPEGS?) via metadata so the image data is not recompressed, but I am intrigued to know what sips setting is for uncompressed (say TIFF) to JPEG?
    I can’t find it in the man page!

  2. steve says:

    is there a way to run sips from command line quietly ie no messages?

  3. Vin says:

    Does sips open .eps images? Any alternative from command line to change the resolution of a .eps image? Thanks

  4. nick says:

    Using this method… is there a way to batch resize images by percentage? ie… resize to 50% of the original size instead of having to specify the resolution.

  5. [...] it still handles batch processing bulk photos just fine. Also, you can tweak and resize images from the command line tool sips, which requires usage of the Terminal and thus may be considered more advanced, but it can be [...]

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