Skip to content

Instantly share code, notes, and snippets.

@turastory
Last active August 12, 2020 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turastory/af8ce76ae9f06db0e7265887784eec40 to your computer and use it in GitHub Desktop.
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.
# 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
# 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"
#!/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
#!/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"
@turastory
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment