Skip to content

Instantly share code, notes, and snippets.

@groupsky
Created January 22, 2013 16:14
Show Gist options
  • Save groupsky/4595920 to your computer and use it in GitHub Desktop.
Save groupsky/4595920 to your computer and use it in GitHub Desktop.
Convert drawable resources from xhdpi to hdpi, mdpi and ldpi
#!/bin/bash
# add desired categories
CATEGORIES=ldpi,mdpi,hdpi
# categories scale in % based on xhdpi
CATEGORIES_SCALE=37.5,50,75
IFS=',' read -a densities <<< "$CATEGORIES"
IFS=',' read -a scales <<< "$CATEGORIES_SCALE"
for index in "${!densities[@]}"
do
echo processig ${densities[index]} resources...
if [ ! -d "res/drawable-${densities[index]}" ]
then
mkdir res/drawable-${densities[index]}
fi
for i in `find res/drawable-xhdpi/ -name *.png`
do
convert $i -resize ${scales[index]}% res/drawable-${densities[index]}/${i##*/}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment