Last active
August 12, 2020 06:51
-
-
Save turastory/af8ce76ae9f06db0e7265887784eec40 to your computer and use it in GitHub Desktop.
A set of scripts for importing icons which are in svg format & resizing rasterized images, into my project.
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
# Head over to where the resources files are located | |
cd ~/Downloads | |
# Run image resizer | |
aaresize --density=xxxhdpi --xxxhdpi --out=. images/* | |
# Check out the files | |
ls -R res |
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
# Head over to where the resources files are located | |
cd ~/Downloads | |
# Run converter | |
~/scripts/svg-converter.sh "icons" "icons-converted" | |
# Run renamer | |
~/scripts/icon-renamer.sh "icons-converted" |
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
#!/bin/bash | |
# | |
# Rename files to follow our resource naming convention | |
# "coupon_line_l.xml" -> "ic_coupon_line_large.xml" | |
if [ "$#" -ne 1 ]; then | |
echo "Illegal number of arguments: $#" | |
exit 2 | |
fi | |
INPUT_DIR=$1 | |
for FILENAME in "$INPUT_DIR"/*; do | |
BASENAME=$(basename "$FILENAME") | |
DIRNAME=$(dirname "$FILENAME") | |
BASENAME_WITHOUT_EXT=${BASENAME%.xml} | |
LAST_CHAR=${FILENAME_WITHOUT_EXT:(-1)} | |
if [ $LAST_CHAR = "l" ]; then | |
FILENAME_WITHOUT_EXT=${FILENAME_WITHOUT_EXT/%l/large} | |
elif [ $LAST_CHAR = "s" ]; then | |
FILENAME_WITHOUT_EXT=${FILENAME_WITHOUT_EXT/%s/short} | |
fi | |
mv $FILENAME "$DIRNAME/ic_$FILENAME_WITHOUT_EXT.xml" | |
done |
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
#!/bin/bash | |
# | |
# Convert svg files into xml files and optimize. | |
if [ "$#" -ne 2 ]; then | |
echo "Illegal number of arguments: $#" | |
exit 2 | |
fi | |
INPUT_DIR=$1 | |
OUTPUT_DIR=$2 | |
s2v -f "$INPUT_DIR" -o "$OUTPUT_DIR" | |
avocado -d "$OUTPUT_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Utilities used