sips
"scriptable image processing system." - sip --help
Examples
Resize a DNG and save the output as JPG
SOURCE=foo.dng
sips --resampleHeightWidthMax 1024 --setProperty format jpeg "$SOURCE" --out "${SOURCE%.dng}.jpg"
Resize all images in the CWD that were taken by the D5100
mdfind -onlyin "$PWD" 'kMDItemAcquisitionModel == "NIKON D5100"' |
while read -r file ; do
sips --resampleHeightWidthMax 1600 --setProperty format jpeg "${file}" --out "${file%.*}.jpg"
done
Resize all images in a dir tree, convert them to jpg and output them to a different folder
In the following example it is important to leave off the trailing slash on the target dir:
SRC_DIR="${HOME}/Pictures/photo_queue"
OUT_DIR="${HOME}/Desktop/Stuff/"
MAX_WIDTH=1600
find "${SRC_DIR}" \
-type f \
-exec sips \
--resampleHeightWidthMax "${MAX_WIDTH}" \
--setProperty format jpeg {} \
--out "${OUT_DIR}" \;