Skip to content

Instantly share code, notes, and snippets.

@sgmonda
Last active February 23, 2021 06:46
Show Gist options
  • Save sgmonda/d697c1d8f9600d50e035c80c4ebba9c9 to your computer and use it in GitHub Desktop.
Save sgmonda/d697c1d8f9600d50e035c80c4ebba9c9 to your computer and use it in GitHub Desktop.
Simple script to convert SVG images into PNGs tinted as white
#!/bin/bash
# Converts provided SVGs into PNGs tinted as white
# Usage:
# $ ./iconmaker.sh in/directory/ out/directory/
IN_DIR=$1
OUT_DIR=$2
TMP_DIR=/tmp
mkdir -p $OUT_DIR
for fname in $(ls $IN_DIR)
do
inpath=$IN_DIR"/"$fname
tmppath=$(echo $TMP_DIR"/"$fname | sed 's/svg$/png/g')
outpath=$(echo $OUT_DIR"/"$fname | sed 's/svg$/png/g')
mogrify -background none -resize 512x512 -format png -path $TMP_DIR $inpath &&
convert -channel RGB -negate $tmppath $outpath
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment