Export SVG to PNG from the command line with Inkscape
Batch-convert SVG assets to PNG using Inkscape 1.x headless mode, with version checks, selective object exports, and font warnings.
13 Jan 2026, 10:54 UTC

You need PNG versions of SVG icons for a deployment pipeline, but the build server has no graphical desktop. Opening Inkscape to click through export dialogs is not an option, and doing it by hand for every asset does not scale.
The useful takeaway: Inkscape 1.x can run headless from a terminal or CI job. A single command converts an SVG file to PNG without opening the application window. The catch is that the CLI flags changed between major versions, fonts must be installed on the export machine, and some Linux builds still need a virtual display.
Check the installed Inkscape version first
Inkscape 0.9.x used --export-png and --export-file. Inkscape 1.x uses --export-type and --export-filename. Scripts written for one release will fail on the other.
Run this in the terminal where the script will execute:
inkscape --version
Look for a 1.x release before using the 1.x flag names. If you see 0.9.x, either upgrade or rewrite the command using the older flags.
Export a whole SVG file to PNG
Run the command from a shell with read access to the input file and write access to the output directory. On a CI runner, that usually means the user executing the pipeline job.
inkscape --export-type=png --export-filename=output.png input.svg
Placeholders:
input.svg: the source SVG file path.output.png: the destination raster file path.
Expected check: after the command finishes, confirm that output.png exists and has non-zero size. You can inspect dimensions with file output.png or an image tool, but do not assume exact pixel counts match a browser render.
Risk: if the SVG references fonts missing from the server, Inkscape substitutes them. Text can shift, wrap differently, or change size in the exported PNG.
Export only one object or layer
When one SVG contains many assets, use --export-id to target a specific element and --export-id-only to exclude everything else.
inkscape --export-id=icon-home --export-id-only \
--export-type=png --export-filename=icon-home.png input.svg
Give the object an id attribute in Inkscape or by editing the SVG XML. The export includes only that object; other layers and shapes are omitted.
Verification: open icon-home.png and confirm it contains only the intended asset. If the file is blank or contains the whole drawing, the ID may not match or --export-id-only may not be supported on that build.
Headless servers may need a virtual framebuffer
Some Inkscape Linux builds initialize GUI subsystems even in CLI mode. On a headless host, the command can fail or hang without a display server.
Run under Xvfb (X virtual framebuffer) if the direct command returns an error related to display or initialization:
xvfb-run --server-args="-screen 0, 1024x768x24" \
inkscape --export-type=png --export-filename=output.png input.svg
Compare the exit code and PNG size against a desktop workstation run to confirm the output is usable.
Limitations to plan around
- Rendering is not guaranteed identical across Inkscape versions, or between Inkscape and web browsers. Filters, blur, and antialiasing can differ.
- Each Inkscape invocation renders one file sequentially. Parallelize at the script level by launching multiple Inkscape processes, not inside Inkscape itself.
- Do not parse console output or rely on exact exit codes for automation logic; these are not a stable contract across releases.
Practical closing checklist
- Run
inkscape --versionon the target machine. - Test one SVG export and inspect the PNG dimensions and appearance.
- Install any fonts used by the SVG on the export host.
- If the server is headless, test with
xvfb-run. - Script the batch job using sequential calls or parallel process management at the shell level.
Once the command works on one file, the same flags can be wrapped in a loop or CI step for the rest of your asset pipeline.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.