Skip to content

Instantly share code, notes, and snippets.

@eusonlito
Last active Oct 17, 2021
Embed
What would you like to do?
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