Skip to content

Instantly share code, notes, and snippets.

@jakkn
Created September 3, 2023 13:09
Show Gist options
  • Save jakkn/2ce1983f0d802733886d8324b02710b3 to your computer and use it in GitHub Desktop.
Save jakkn/2ce1983f0d802733886d8324b02710b3 to your computer and use it in GitHub Desktop.
SVG to Avatar
#!/bin/bash
INPUT_FILE=$1
BG_COLOR=${2:transparent} # May be hex code or color name
if [ -z "$INPUT_FILE" ]; then
echo "Usage: $0 <input.svg> <bg-color>"
exit 1
fi
INPUT_FILE_AS_PNG="$(basename "$INPUT_FILE" .svg ).png"
inkscape -w 250 -h 250 "$INPUT_FILE" -o "$INPUT_FILE_AS_PNG"
convert "$INPUT_FILE_AS_PNG" -background "$BG_COLOR" -gravity center -scale 250x250 -extent 400x400 "$INPUT_FILE_AS_PNG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment