Skip to content

Instantly share code, notes, and snippets.

@JayNewstrom JayNewstrom/
Last active Aug 29, 2015

What would you like to do?
Resize image assests, starting with an image in your res/drawable-xxxhdpi folder.

Origionally based off:


chmod +x

copy to res/drawable-xxxhdpi/


Start with the image you want to resize, we'll call it resize_me.png (remember, android resources can't have caps, or dashes)

copy resize_me.png to res/drawable-xxxhdpi/resize_me.png

./ resize_me.png

# fake argv and argc in bash
argc=$#; argv[0]=$0 # argv[0] is a prog name
for foo in $( seq $argc )
eval "argv[${foo}]=\$${foo}"
width=$(sips -g pixelWidth $filename | tr -d '\n' | awk '{ print $NF }')
sips --resampleWidth $(($width/4)) "${filename}" --out "../drawable/${filename}"
sips --resampleWidth $(($width/8*3)) "${filename}" --out "../drawable-hdpi/${filename}"
sips --resampleWidth $(($width/2)) "${filename}" --out "../drawable-xhdpi/${filename}"
sips --resampleWidth $(($width/4*3)) "${filename}" --out "../drawable-xxhdpi/${filename}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.