Skip to content

Instantly share code, notes, and snippets.

@xgouchet
Created January 7, 2019 12:31
Show Gist options
  • Save xgouchet/fdeaf6d4b819d8c739e33b827100b6c4 to your computer and use it in GitHub Desktop.
Save xgouchet/fdeaf6d4b819d8c739e33b827100b6c4 to your computer and use it in GitHub Desktop.
Exports an svg image into png images for Android consumption
# usage export_svg source.svg output.png sizedp
function export_svg() {
mkdir -p "drawable-ldpi"
size=$(($3 * 3 / 4))
inkscape -z -e "drawable-ldpi/$2" -w $size -h $size "$1"
mkdir -p "drawable-mdpi"
size=$(($3))
inkscape -z -e "drawable-mdpi/$2" -w $size -h $size "$1"
mkdir -p "drawable-hdpi"
size=$(($3 * 3 / 2))
inkscape -z -e "drawable-hdpi/$2" -w $size -h $size "$1"
mkdir -p "drawable-xhdpi"
size=$(($3 * 2))
inkscape -z -e "drawable-xhdpi/$2" -w $size -h $size "$1"
mkdir -p "drawable-xxhdpi"
size=$(($3 * 3))
inkscape -z -e "drawable-xxhdpi/$2" -w $size -h $size "$1"
mkdir -p "drawable-xxxhdpi"
size=$(($3 * 4))
inkscape -z -e "drawable-xxxhdpi/$2" -w $size -h $size "$1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment