Last active
November 9, 2016 02:07
-
-
Save sarah-j-smith/25a54689ffbbdbcce8ab to your computer and use it in GitHub Desktop.
Create SD, Retina and @3x Images of a given size.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.