When working with images on macOS, most users rely on the built-in Preview application or third-party tools like Adobe Photoshop. However, for users who need to resize, convert, or rotate hundreds of images quickly, doing this manually through a graphical interface is incredibly tedious.
macOS includes a powerful, built-in command-line image processing tool called sips (Scriptable Image Processing System). Available directly in the Terminal, sips allows you to perform high-quality image manipulation instantly, making it perfect for batch processing and automated workflows.
Converting Image Formats
One of the most common uses for sips is converting images from one format to another (for example, converting a batch of PNG screenshots to JPEGs to save disk space).
To convert a single image from PNG to JPEG:
sips -s format jpeg input.png --out output.jpg
The -s format flag specifies the target format. Supported formats include jpeg, tiff, png, gif, jp2, pict, bmp, qtif, and psd.
If you do not specify an --out path, sips will overwrite the original file in place (though it will complain if the extension doesn’t match the new format). It is always safer to specify an output file.
Resizing Images
The sips command offers several ways to resize images. This is particularly useful for web developers who need to generate thumbnails.
Resizing by Exact Dimensions
To force an image to a specific width and height (ignoring the original aspect ratio):
sips -z 300 400 image.jpg
This command resizes the image to 300 pixels high by 400 pixels wide (note that sips expects the height first, then the width). Because we did not specify an --out file, this command modifies image.jpg directly.
Resizing While Maintaining Aspect Ratio
To avoid stretching or squashing the image, you can tell sips to resize the image so that its longest side fits a maximum dimension. The command will automatically calculate the other side to preserve the aspect ratio.
To scale an image so its maximum dimension is 800 pixels:
sips -Z 800 image.jpg
(Note the capital -Z instead of the lowercase -z used for exact dimensions).
Rotating and Flipping Images
You can use sips to correct orientation issues rapidly.
To rotate an image 90 degrees clockwise:
sips -r 90 image.jpg
To flip an image horizontally (creating a mirror image):
sips -f horizontal image.jpg
To flip an image vertically (upside down):
sips -f vertical image.jpg
Reading Image Metadata
The sips command isn’t just for modifying images; it is also an excellent tool for inspecting them. You can use it to read the internal EXIF data and properties of an image file.
To dump all available properties of an image:
sips -g all image.jpg
To query a specific property, such as the exact pixel dimensions:
sips -g pixelWidth -g pixelHeight image.jpg
This command outputs clean, structured data that is easy to capture in a shell script variable.
Batch Processing Images
The true power of sips is unleashed when you combine it with standard Unix shell scripting tools to process entire directories of images at once.
For example, if you have a folder full of high-resolution `.png` images and you want to convert all of them to `.jpg` format, resize them to a maximum width of 1000 pixels, and save them in a new “processed” folder, you can use a simple Bash loop:
mkdir processed
for file in *.png; do
sips -s format jpeg -Z 1000 "$file" --out "processed/${file%.png}.jpg"
done
This short script takes what would be an hour of manual work in an image editor and completes it flawlessly in seconds. By incorporating sips into your macOS toolkit, you gain a highly efficient, scriptable alternative to heavyweight graphics software.