Skip to content

Instantly share code, notes, and snippets.

@eusonlito
Last active October 17, 2021 18:47
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 eusonlito/bc8668b152aeb397ebc8b86f2ebf95a6 to your computer and use it in GitHub Desktop.
Save eusonlito/bc8668b152aeb397ebc8b86f2ebf95a6 to your computer and use it in GitHub Desktop.
Convert SVG to PNG using inkscape CLI
#!/bin/bash
for svg in */*.svg; do
width=$(grep -m 1 -o -h 'width="[0-9]\+"' $svg | sed 's/[^0-9]//g')
height=$(grep -m 1 -o -h 'height="[0-9]\+"' $svg | sed 's/[^0-9]//g')
png=$(echo $svg | sed 's/svg/png/')
echo "Converting $svg to $png with size ${width}x${height}"
inkscape -w "$width" -h "$height" $svg -o $png 2>/dev/null
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment