Created
November 20, 2013 03:48
-
-
Save trdarr/7557395 to your computer and use it in GitHub Desktop.
Scale and export (SVG, MDPI / non-Retina) app assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# vim: set ft=sh | |
mkdir -p ios | |
mkdir -p res/drawable-{mdpi,hdpi,xhdpi,xxhdpi,xxxhdpi} | |
scale () { | |
infile=$1 | |
outfile=${infile%.svg} | |
# 2x: iOS non-Retina / Android MDPI | |
rsvg-convert "$infile" > "res/drawable-mdpi/${outfile}.png" | |
cp "res/drawable-mdpi/${outfile}.png" "ios/${outfile}.png" | |
# 3x: Android HDPI (and, downscaled, LDPI) | |
rsvg-convert -z 1.5 "$infile" > "res/drawable-hdpi/${outfile}.png" | |
# 4x: iOS Retina / Android XHDPI | |
rsvg-convert -z 2.0 "$infile" > "res/drawable-xhdpi/${outfile}.png" | |
cp "res/drawable-xhdpi/${outfile}.png" "ios/${outfile}@2x.png" | |
# 6x: Android XXHDPI | |
rsvg-convert -z 3.0 "$infile" > "res/drawable-xxhdpi/${outfile}.png" | |
# 8x: Android XXXHDPI | |
rsvg-convert -z 4.0 "$infile" > "res/drawable-xxxhdpi/${outfile}.png" | |
} | |
if [ $# -gt 0 ]; then | |
for infile in "$@"; do | |
scale "$infile" | |
done | |
else | |
for infile in *.svg; do | |
scale "$infile" | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rsvg-convert
comes from librsvg (brew install librsvg
).