EN
Inkscape - batch export / convert svg graphics to png from bash console
7 points
Using Inkscape and Bash on Microsoft Windows it is possible to export many *.svg
graphics to *.png
in the following way.
Note: in the below scripts we use
inkscape
command described in this article.
Note: to know how to install Bash under Windows go to this article.
export-1x1.sh
file:
xxxxxxxxxx
1
2
3
program="/C/Program Files/Inkscape/bin/inkscape.exe"
4
# program="/C/Program Files/Inkscape/inkscape.exe"
5
6
target="png-$1"
7
8
mkdir "${target}"
9
10
for i in *.svg
11
do
12
"${program}" --export-type="png" --export-filename="${target}/${i}.png" -w $1 -h $1 "${i}"
13
14
# "${program}" -z -e "${target}/${i}.png" -w $1 -h $1 "${i}"
15
done
Notes:
export-1x1.sh
file should be placed in the*.svg
graphics directory,program
variable should be updated with actualinkscape.exe
path.
Running:
xxxxxxxxxx
1
./export-1x1.sh 40
Note:
40
means the size of output graphics will be 40x40 px.
export.sh
file:
xxxxxxxxxx
1
2
3
# program="/C/Program Files/Inkscape/inkscape.exe"
4
program="/C/Program Files/Inkscape/bin/inkscape.exe"
5
6
target="png-${1}x${2}"
7
8
mkdir "${target}"
9
10
for i in *.svg
11
do
12
"${program}" --export-type="png" --export-filename="${target}/${i}.png" -w "$1" -h "$2" "${i}"
13
14
# "${program}" -z -e "${target}/${i}.png" -w "$1" -h "$2" "${i}"
15
done
Running:
xxxxxxxxxx
1
./export.sh 40 50
Note:
40 50
means the size of output graphics will be 40x50 px.