Skip to content

Instantly share code, notes, and snippets.

@sarah-j-smith
Last active November 9, 2016 02:07
Show Gist options
  • Save sarah-j-smith/25a54689ffbbdbcce8ab to your computer and use it in GitHub Desktop.
Save sarah-j-smith/25a54689ffbbdbcce8ab to your computer and use it in GitHub Desktop.
Create SD, Retina and @3x Images of a given size.
#!/bin/sh
filename=$(basename "$1")
extension="${filename##*.}"
filename="${filename%.*}"
if [ -z $1 ]; then
echo "Usage: $0 image.png <points wide>"
echo " produces 3 copies of the image, in SD, @2x and @3x for that point size"
exit;
fi
src=$1
w=$2
sips -s format png --resampleWidth $w $src --out "${filename}.png"
sips -s format png --resampleWidth $(($w * 2)) $src --out "${filename}@2x.png"
sips -s format png --resampleWidth $(($w * 3)) $src --out "${filename}@3x.png"
@sarah-j-smith
Copy link
Author

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

Note that the script also converts the files to PNG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment