Created
October 28, 2019 13:36
-
-
Save vithonch/4c5f0382dece3ea4ebab8028bc25d7e6 to your computer and use it in GitHub Desktop.
svg2png
This file contains hidden or 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
rsvg-convert -v > /dev/null 2>&1 || { echo "rsvg-convert is not installed, use: brew install librsvg." >&2; exit 1; } | |
ASSETS_FOLDER=$1 | |
if [ "$ASSETS_FOLDER" == "" ]; then | |
echo "Usage: $0 /path/to/svg/assets/" >&2 | |
exit 1 | |
fi | |
if [ ! -d "$ASSETS_FOLDER" ]; then | |
echo "$ASSETS_FOLDER path not found" >&2 | |
exit 1 | |
fi | |
for FILE_PATH in $(find $ASSETS_FOLDER -name '*.svg'); do | |
PATH_NO_EXT="${FILE_PATH%.*}" | |
echo $FILE_PATH | |
rsvg-convert $FILE_PATH -o "${PATH_NO_EXT}.png" | |
rsvg-convert $FILE_PATH -x 2 -y 2 -o "${PATH_NO_EXT}@2x.png" | |
rsvg-convert $FILE_PATH -x 3 -y 3 -o "${PATH_NO_EXT}@3x.png" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment