Skip to content

Instantly share code, notes, and snippets.

@Sefford
Last active September 3, 2015 16:10
Show Gist options
  • Save Sefford/afb919bd2846dfd66183 to your computer and use it in GitHub Desktop.
Save Sefford/afb919bd2846dfd66183 to your computer and use it in GitHub Desktop.
Bash Script for using Inkscape to convert from vectorial to PNG
#!/bin/sh
#Usage: export.sh <name of file> <width> <height>
mkdir -p drawable-mdpi
mkdir -p drawable-hdpi
mkdir -p drawable-xhdpi
mkdir -p drawable-xxhdpi
mkdir -p drawable-xxxhdpi
inkscape $1 --export-png=./drawable-mdpi/${1%.*}.png -w$2 -h$3 --export-area-page
inkscape $1 --export-png=./drawable-hdpi/${1%.*}.png -w$(echo "$2*1.5" | bc) -h$(echo "$3*1.5" | bc) --export-area-page
inkscape $1 --export-png=./drawable-xhdpi/${1%.*}.png -w$(($2 * 2)) -h$(($3 * 2)) --export-area-page
inkscape $1 --export-png=./drawable-xxhdpi/${1%.*}.png -w$(($2 * 3)) -h$(($3 * 3)) --export-area-page
inkscape $1 --export-png=./drawable-xxxhdpi/${1%.*}.png -w$(($2 * 4)) -h$(($3 * 4)) --export-area-page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment