Skip to content

Instantly share code, notes, and snippets.

@aminelaadhari
Forked from ignasi/resizer-xxhdpi.sh
Created February 3, 2014 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aminelaadhari/8793513 to your computer and use it in GitHub Desktop.
Save aminelaadhari/8793513 to your computer and use it in GitHub Desktop.
#!/bin/bash
f=$(pwd)
mkdir drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi
# fake argv and argc in bash
argc=$#; argv[0]=$0 # argv[0] is a prog name
for foo in $( seq $argc )
do
eval "argv[${foo}]=\$${foo}"
filename=${argv[$foo]}
width=$(sips -g pixelWidth $filename | tr -d '\n' | awk '{ print $NF }')
sips --resampleWidth $(($width/3)) "${f}/${filename}" --out "${f}/drawable-mdpi/${filename}"
sips --resampleWidth $(($width/2)) "${f}/${filename}" --out "${f}/drawable-hdpi/${filename}"
sips --resampleWidth $(($width/3*2)) "${f}/${filename}" --out "${f}/drawable-xhdpi/${filename}"
sips --resampleWidth $width "${f}/${filename}" --out "${f}/drawable-xxhdpi/${filename}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment