Created
July 23, 2017 07:48
-
-
Save peterp/1051825fa84f20cb943e303f09f6775c to your computer and use it in GitHub Desktop.
React Native: Convert SVG images to PNG images
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
#!/bin/sh | |
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 |
How do i use this in react-native ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing! The only script that worked for me!