Skip to content

Instantly share code, notes, and snippets.

Last active October 17, 2021 18:47
What would you like to do?
Convert SVG to PNG using inkscape CLI
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
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment