How to resize images using terminal on Mac OSX?

Here is script that uses sips to recursively resize all the images in a given folder (and its sub-folders), and places the resized images in a resized folder on the same tree level as the image: https://gist.github.com/lopespm/893f323a04fcc59466d7

#!/bin/bash
# This script resizes all the images it finds in a folder (and its subfolders) and resizes them
# The resized image is placed in the /resized folder which will reside in the same directory as the image
#
# Usage: > ./batch_resize.sh

initial_folder="/your/images/folder" # You can use "." to target the folder in which you are running the script for example
resized_folder_name="resized"

all_images=$(find -E $initial_folder -iregex ".*\.(jpg|gif|png|jpeg)")

while read -r image_full_path; do
    filename=$(basename "$image_full_path");
    source_folder=$(dirname "$image_full_path");
    destination_folder=$source_folder"/"$resized_folder_name"/";
    destination_full_path=$destination_folder$filename;

    if [ ! -z "$image_full_path" -a "$image_full_path" != " " ] &&
        # Do not resize images inside a folder that was already resized
        [ "$(basename "$source_folder")" != "$resized_folder_name" ]; then 

        mkdir "$destination_folder";
        sips -Z 700 "$image_full_path" --out "$destination_full_path";

    fi

done <<< "$all_images"

As pointed out by LifeHacker, the following command will do this very easily:

sips -Z 640 *.jpg

To quote their explanation:

"sips is the command being used and -Z tells it to maintain the image's aspect ratio. "640" is the maximum height and width to be used and "*.jpg" instructs your computer to downsize every image ending in .jpg. It's really simple and shrinks your images very quickly. Be sure to make a copy first if you want to preserve their larger size as well."

Source: http://lifehacker.com/5962420/batch-resize-images-quickly-in-the-os-x-terminal


imagemagick helps:

$ convert foo.jpg -resize 50% bar.jpg

There are a lot more things it can do, including the conversion between formats, applying effects, crop, colorize and much, much more.