On macOS, you can batch-resize a group of images with the built-in sips command by giving it a maximum pixel height and width, then applying the command to the files you select. For example, a shell loop can resize every JPEG in a folder while leaving the originals untouched in a separate output folder.
What sips does when resizing
sips is a macOS command-line tool for inspecting and editing image files. Its --resampleHeightWidth option changes pixel dimensions; it does not simply change a print-size label or compress files to a target file size. Use sips --help in Terminal to see the options available on your Mac.
For batch work, the key is passing the same resizing command to multiple paths. A reliable approach is to loop through matching files, write each result to a different directory, and avoid overwriting the source. The examples below use JPEG files, but sips supports several common image formats. Confirm the format and options against the files you actually have.
Resize one image first
Before processing a whole folder, test the command on one copy. Make an output directory, then run:
mkdir -p resized
sips --resampleHeightWidth 1200 1600 photo.jpg --out resized/photo.jpg
The two numbers specify height followed by width, in pixels. The output image is constrained to fit within 1200 pixels high and 1600 pixels wide while keeping its aspect ratio. A landscape image wider than the limit will usually be reduced to the width limit; a portrait image taller than the height limit will usually be reduced to the height limit. The resulting dimensions can be smaller than both limits.
Check the result with sips -g pixelWidth -g pixelHeight resized/photo.jpg. If the displayed dimensions are not what you expect, verify the order of the two limits and whether the source image already fits within them.
Batch-resize JPEGs in a folder
In Terminal, change to the directory containing the JPEGs, or replace *.jpg with a suitable path. This loop handles filenames containing spaces and saves results under resized:
mkdir -p resized
for f in *.jpg; do
[ -e "$f" ] || continue
sips --resampleHeightWidth 1200 1600 "$f" --out "resized/$f"
done
The file-existence check prevents the loop from trying to process the literal pattern when there are no matching files. The quoted variables keep names such as holiday photo.jpg together as one path. If your files use uppercase extensions, add another loop for *.JPG, or use the more flexible find-based method below.
To process PNGs instead, change the pattern to *.png and use a separate output directory if you want to keep formats organized. Avoid using the same source and output path unless you intentionally want to replace the original; a separate folder gives you a straightforward way to compare results and recover from mistakes.
Include files in subfolders
For images nested in subdirectories, find can locate files recursively. This example writes every matching JPEG to one output folder using its original filename:
mkdir -p resized
find . -type f \( -iname '*.jpg' -o -iname '*.jpeg' \) -print0 |
while IFS= read -r -d '' f; do
name=${f##*/}
sips --resampleHeightWidth 1200 1600 "$f" --out "resized/$name"
done
-print0 and the matching read option allow filenames with spaces and many special characters. However, flattening a directory tree can create name collisions: two different folders might contain a file called cover.jpg, and both would be directed to the same output path. For large collections, preserve the folder structure or process one directory at a time rather than flattening everything.
Choose the right dimensions and format
Set limits based on where the images will be used. A website thumbnail, presentation, or email attachment may need fewer pixels than an image intended for a large display. Resizing downward discards image detail; increasing dimensions does not restore detail that was not present in the original.
- Use maximum dimensions when images have mixed orientations or aspect ratios. A height-and-width limit allows each image to fit within a box without forcing every image to the same exact shape.
- Use exact dimensions only when required. Exact width-and-height resizing can distort an image if its original proportions differ. Cropping is a different operation and may be preferable when a fixed shape is essential.
- Check the output format. Resizing is separate from format conversion and quality settings. Do not assume that changing dimensions automatically converts every file or reduces its file size by a predictable amount.
- Keep originals until checked. Compare representative output files and inspect their pixel dimensions before deleting or replacing source images.
Common problems and checks
If Terminal reports that no files were found, check that you are in the intended folder with pwd and list its contents with ls. Shell patterns such as *.jpg match names in the current directory, not files in every nested folder; use find for recursion.
If an image seems unchanged, it may already be smaller than the requested maximum. Resampling to a larger limit does not necessarily mean the image will be enlarged; inspect the output with sips -g pixelWidth -g pixelHeight. Also check whether the file extension matches its actual format and whether the command produced an error for that particular file.
Resizing changes pixel dimensions, not necessarily the file’s metadata, orientation handling, compression quality, or color profile in the way a particular workflow requires. If those details matter, inspect sample outputs and consult sips --help for relevant options. Keep a backup before using commands that overwrite files.
Frequently Asked Questions
Does sips preserve the image’s aspect ratio?
When using --resampleHeightWidth as a maximum height-and-width constraint, the image is resized to fit within those bounds rather than stretched to fill both dimensions. Check the resulting pixel dimensions, especially if you require exact output sizes.
Are the sips dimensions height first or width first?
For --resampleHeightWidth, enter height first and width second. For a 1200-by-1600-pixel maximum in the sense of 1200 pixels wide and 1600 high, use --resampleHeightWidth 1600 1200.
Can sips resize PNG and HEIC files too?sips handles multiple image formats, including common formats such as PNG and HEIC on supported macOS installations. Try the command on a copy and check the tool’s help or the file’s reported properties if a format fails.
How can I resize images without overwriting them?
Use --out with a different destination path, as in the examples, and create an output directory first. This keeps the originals available for comparison or recovery.
Can sips make every image exactly the same width and height?
Not while also preserving different original proportions through a simple maximum-size resize. Exact matching dimensions may require cropping or distortion, so choose the operation that fits your intended use.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Valheim Server Not Showing in Community List Fixes
- DisplayPort vs HDMI: Which Cable Should You Use?
- Soundbar vs 2.1 Speaker System: Which Is Better?
- Survive Lava for Brainrot Tier List170 points
- MySQL Dump Import: Fix Common Errors
- Mouse Moving on Its Own? Causes & Fixes