Skip to content

Use sips to quickly, easily—and freely—convert image files

Quite often, I find myself with a number of images (screenshots, typically) that I'll want to convert from one format to another. If you search the Mac App Store, there are probably 300 apps that will let you do this; many are probably free. You could also use Automator, which has some good image conversion abilities, but can't (for example) specify the quality of a JPEG conversion.

But the best way I've ever found is to use a tool that's been included with every copy of macOS since the release of Mac OS X 10.3 (Panther) in October of 2003: A command line tool called sips. Yes, it requires using Terminal, but it's quite easy to use. sips can modify one file, or any number of files, converting from one format to another. You can also use sips to resize images, rotate images, and more.

Basic usage of sips is straightforward. (The following is written for Terminal neophytes, so apologies for any over-explaining). Assume you have an image named Beach party.tiff that you'd like to convert into a smaller JPEG, but with a relatively high quality setting. Here's how you'd do it using sips:

  1. Open Terminal, in Applications > Utilities.
  2. Type cd, then press the Space Bar, then drag in the folder that contains the image(s) to be converted. (Alternatively, you can use this tip to directly open the selected Finder folder in Terminal.)
  3. Type this, then press Return: sips -s format jpeg -s formatOptions 80 "Beach party.tiff" --out "Beach party.jpg"

When you press Return, sips will convert your image file—and it's really fast, even on larger files. The formatOptions item lets you set the quality of the JPEG in either percentage (as I used), or you can use words: low, normal, high, or best. Hopefully obviously, you specify the new filename after the --out string.

Note that the filename is enclosed in quotes. Those quotes are required, otherwise any spaces in your filenames will cause the command to break.

The real power of sips isn't in converting one file, though; it's in batch converting many files. Here's how to do that…

Batch conversions are essentially the same as single-file conversions, but it's a bit trickier due to how Terminal processes multiple files. Here's a real-world example: I have a folder of 24 large (1.5MB to 2MB each) PNG files that I want to convert to JPEGs while keeping the original files intact. Once I'm in the proper directory (steps one and two in the above process), I need to use a loop to read all the PNG files, and convert each one with sips. That loop command looks like this:

for i in *.png; do sips -s format jpeg -s formatOptions 70 "${i}" --out "${i%png}jpg"; done

This looks a bit scary, but it's not too bad, given that there's very little that needs to change when you use it: The only bits that you need to modify are:

  • for i in *.png; - This is the loop, and in my case, it's looking for files with the png extension. Change to match the type of the "source" images you want to modify.
  • -s format jpeg - This sets the format for the new file to JPEG. Format can be any of jpeg | tiff | png | gif | jp2 | pict | bmp | qtif | psd | sgi | tga.
  • -s formatOptions 70 - This sets the JPEG quality to 70%. If the chosen image format doesn't support a quality setting (i.e. PNG), you can just leave this off.
  • "${i%png}jpg" - This bit of magic removes the old file extension (png) and adds the new one (jpg). If you convert from .tiff to .png, you'd want it to read "${i%tiff}png"

sips is really fast, too—much faster than it'd be if I had to open an app to use its batch convert feature. Here's how quickly it converted 24 PNGs totalling 40MB in size:

That took only 1.332 seconds for all 24 files; just launching a batch image editor would take roughly that long. Speed is good!

I recommend you play around with sips and copies of your images to see what it can do. I'd also normally recommend reading the sips man page (man sips), but it's really not all that helpful.

Instead, try searching the web for examples of how to put sips to use. You can start with some examples on my old macosxhints.com site. This page explains how you can use sips to resize and constrain images to a bounding box. Finally, this one discusses rotation and flipping.

I'm sure there are GUI apps built on top of sips, such that you wouldn't have to touch Terminal. But for me, it's easy enough to switch in, do what I want, and switch out that I haven't bothered looking for a GUI solution.

11 thoughts on “Use sips to quickly, easily—and freely—convert image files”

      1. Before I actually do anything with find, I have "print" as the only action so I can make sure that only the files I want are acted on.

    1. Make sure you set it up as a Service (File > New > Service), and then set the "Service receives selected" pop-ups to 'image files' and 'Finder.' Set up the rest, save the Service, then just select a bunch of image files in Finder and choose your service from the Finder > Services menu (or the contextual menu).

      regards;
      -rob.

        1. Sorry, I think I misunderstood what you were asking. You can make this work on batches in Automator by wrapping the sips command you want to use in a "for" loop, like this:

          That would resample all selected images to 1024 pixels in width. You can make "for f" into whatever var you want to use, i.e. "for myPix." But if you change it, you also need to change the "$f" in the sips command to whatever you used, i.e. "$myPix".

          Also make sure the Pass Input pop-up at the top right of Automator's shell script action is set to "as arguments," otherwise this won't work.

          -rob.

          1. Hi Rob,

            Thanks so much for your support. It seem that you are guiding me on a good path.
            It didn't work unfortunately for me up to now. Did i miss something ?

            Here is the code I entered :

            for xy in "$@"; do
            sips --s dpiHeight 72 --s dpiWidth 72 "$xy"
            done

            And the error message I get :

            Error 1: unknown function "--s"
            Try 'sips --help' for help using this tool

            Which is strange since the --s is needed for editing purpose and worked fine for single edit as :

            sips --s dpiHeight 72 --s dpiWidth 72 "$1"

            Best.

  1. Thibault:

    I think you have a wrong hyphen or quote or something; it worked fine for me. Please copy the below quoted code:

    That should work—it does here, at any rate.

    -rob.

  2. Splendid !! You saved my life, a lot of space on my Mac and my headach :-D

    It seem that I needed only one " - " instead of two in front of the " --s " , while it worked for single files.

    Great job, great blog.

    PS : I was also looking to this Fuji scanner ;-)

  3. Stumbled onto this page while looking for something. May as well share what I came up with for resizing/reformatting HEIC to PNG:

Comments are closed.