EN
Inkscape - how to convert svg to png in console?
13
points
Using Inkscape and Bash it is possible to *.svg
file to *.png
in the following way.
Quick solution:
"/C/Program Files/Inkscape/bin/inkscape.exe" --export-type="png" --export-filename="output_file.png" -w 100 -h 40 "input_file.svg"
1. Inkscape and Bash console under Microsoft Windows example
When we have installed Inkscape under Windows we are able to use the command line to make some SVG files conversion,
1.1. With the exact size
"/C/Program Files/Inkscape/bin/inkscape.exe" --export-type="png" --export-filename="output_file.png" -w 100 -h 40 "input_file.svg"
or:
# Older Inkscape:
"/C/Program Files/Inkscape/inkscape.exe" -z -e "output_file.png" -w 100 -h 40 "input_file.svg"
Note:
-w 100 -h 40
means the size of output graphics will be 100x40 px.
Example output:
Background RRGGBBAA: ffffff00
Area 0:0:1199.79:3284.24 exported to 100 x 40 pixels (1.16922 dpi)
Bitmap saved as: output_file.png
1.2. With keeping ratio and scaling to width
Using this approach height will be computed automatically to keep the original width/height
proportion.
$ "/C/Program Files/Inkscape/bin/inkscape.exe" --export-type="png" --export-filename="output_file.png" -w 100 "input_file.svg"
or:
# Older Inkscape:
"/C/Program Files/Inkscape/inkscape.exe" -z -e "output_file.png" -w 100 "input_file.svg"
Example output:
Background RRGGBBAA: ffffff00
Area 0:0:1199.79:3284.24 exported to 100 x 274 pixels (8.0014 dpi)
Bitmap saved as: output_file.png
1.3. With keeping ratio and scaling to height
Using this approach width will be computed automatically to keep the original width/height
proportion.
$ "/C/Program Files/Inkscape/bin/inkscape.exe" --export-type="png" --export-filename="output_file.png" -h 300 "input_file.svg"
or:
# Older Inkscape:
"/C/Program Files/Inkscape/inkscape.exe" -z -e "output_file.png" -h 300 "input_file.svg"
Example output:
Background RRGGBBAA: ffffff00
Area 0:0:1199.79:3284.24 exported to 110 x 300 pixels (8.76915 dpi)
Bitmap saved as: output_file.png