How to Use the sips Command in macOS Terminal to Batch Convert, Resize, and Rotate Images

Digital photographers, web designers, and macOS power users frequently need to process large batches of images—resizing photography collections, converting raw HEIC captures into web-ready JPEG or PNG formats, stripping extraneous metadata, or applying batch rotations. While commercial software and GUI utilities like Preview can handle basic adjustments, executing batch operations across hundreds of assets via graphical interfaces consumes excessive memory and manual effort. macOS contains a high-performance, native image processing engine accessible directly from the command line: the Scriptable Image Processing System (sips).

Because sips is built into Darwin core and leverages Apple’s hardware-accelerated Core Graphics frameworks, it processes images significantly faster than third-party interpreted scripts or web-based converters. It operates natively on Apple silicon without requiring Homebrew installations or external binary dependencies like ImageMagick. This comprehensive technical guide details the capabilities of sips, its command-line syntax, and how to execute batch conversions, aspect-ratio-preserving resizes, canvas padding, and color profile embeddings.

Key Syntax and Operational Flags of sips

The sips utility follows a structured command syntax: sips [options] imagefile ... [--out destinationfile]. When modifying files without specifying --out, sips modifies the source image in place. Essential operational flags include:

Operational Flag Function Description Typical Command Example
-s format <type> Converts file to target format (jpeg, png, tiff, heic, pdf, gif). sips -s format png photo.heic --out photo.png
-s formatOptions <val> Configures compression quality (low, normal, high, best, or 0–100 integer). sips -s formatOptions 80 photo.jpg
-z <height> <width> Forces explicit pixel dimensions (ignores aspect ratio). sips -z 1080 1920 banner.png
-Z <pixels> Resizes proportionally so the longest edge does not exceed specified pixels. sips -Z 1200 image.jpg
-r <degrees> Rotates image clockwise by degrees (90, 180, 270). sips -r 90 photo.jpg
-f <horizontal|vertical> Flips the image along the horizontal or vertical axis. sips -f horizontal mirror.png
-g <property> Queries and prints image properties (e.g., pixelWidth, dpiWidth, space). sips -g pixelWidth -g pixelHeight photo.jpg

Querying Image Metadata and Dimensions

Before applying transformations, you can inspect internal dimensions and colour profile parameters using query flags:

# Query specific dimensions
sips -g pixelWidth -g pixelHeight sample.jpg

# Inspect complete image metadata and ICC profile
sips -g all sample.jpg

The output returns structured key-value pairs directly in Terminal:

sample.jpg
  pixelWidth: 4032
  pixelHeight: 3024
  typeIdentifier: public.jpeg
  format: jpeg
  space: RGB
  profile: Display P3

Batch Converting Image Formats (HEIC to JPEG/PNG)

iPhone camera systems default to capturing high-efficiency HEIC files, which often require conversion to standard JPEG format for web compatibility. You can convert entire directories of HEIC files using a native Zsh shell loop:

# Create an output directory
mkdir -p ./converted_jpg

# Batch convert all HEIC files to high-quality JPEG
for img in *.HEIC; do
  sips -s format jpeg -s formatOptions 85 "$img" --out "./converted_jpg/${img%.*}.jpg"
done

To convert from JPEG to transparent PNG:

# Convert single image to PNG
sips -s format png input.jpg --out output.png

Proportional Resizing and Dimension Constraints

When preparing assets for content management systems or social media, maintaining aspect ratio while limiting maximum file dimensions is critical.

1. Proportional Downscaling with Maximum Edge Clamping

The uppercase -Z flag scales images dynamically, ensuring neither height nor width exceeds the threshold while preserving exact proportions:

# Scale single image so longest edge is 1600px
sips -Z 1600 hero_banner.png --out hero_banner_optimized.png

# Batch process an entire folder of photos in-place
sips -Z 1200 *.jpg

2. Resizing with Explicit Width or Height Clamping

To scale an image based on a fixed width while allowing the height to adjust automatically proportionally, combine --resampleWidth:

# Clamp width to 800px; auto-calculate height
sips --resampleWidth 800 diagram.png

# Clamp height to 600px; auto-calculate width
sips --resampleHeight 600 diagram.png

Padding, Cropping, and Canvas Adjustments

Beyond scaling, sips can alter canvas geometry and pad boundaries with solid colour:

Task Command Invocation Description
Crop Centred Box sips -p 800 800 photo.jpg Crops or pads the image to an exact 800×800 square, anchoring to the centre.
Custom Pad Colour sips --padToHeightWidth 1000 1000 --padColor FFFFFF photo.png Expands the canvas to 1000×1000 pixels, filling empty borders with solid white.
Remove EXIF Metadata sips -d profile --deleteColorManagementProperties photo.jpg Purges embedded metadata and color tags to minimize payload footprint.

Automating Workflow via macOS Shell Scripts

Combine multiple sips flags into a streamlined shell script to generate web-ready image packages automatically:

#!/bin/zsh
# web-optimize.sh: Batch resize and convert images for web publication

mkdir -p web_dist

for file in *.{jpg,jpeg,png,heic}(N); do
  echo "Processing: $file"
  sips -s format jpeg \
       -s formatOptions 80 \
       -Z 1400 \
       "$file" \
       --out "web_dist/${file%.*}.jpg"
done

echo "Batch optimisation complete. Check ./web_dist directory."

Troubleshooting Common sips Errors

Error Message / Symptom Root Cause Remediation Step
Error: ... unrecognized format Unsupported file container or invalid format argument. Ensure format strings are lowercase (e.g., jpeg, png, not JPG).
Original file overwritten unintentionally Omitting the --out parameter. Always supply --out path/to/output.jpg if preserving original source media is required.
Distorted image aspect ratio Using forced dimension flag -z instead of proportional -Z. Replace -z <h> <w> with -Z <pixels> or --resampleWidth.
Permission denied Restricted write access to target folder or read-only volume. Verify directory write permissions using chmod u+w or run within the user home tree.

By integrating the native sips command-line utility into terminal routines and deployment scripts, macOS developers and photographers can execute rapid, zero-dependency batch image transformations directly on Apple hardware.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.