LinuxCommandLibrary

rsvg-convert

TLDR

Convert SVG to PNG

$ rsvg-convert [input.svg] -o [output.png]
copy
Convert to PDF
$ rsvg-convert -f pdf [input.svg] -o [output.pdf]
copy
Resize output
$ rsvg-convert -w [800] -h [600] [input.svg] -o [output.png]
copy
Set DPI
$ rsvg-convert -d [300] [input.svg] -o [output.png]
copy

SYNOPSIS

rsvg-convert [options] [files...]

DESCRIPTION

rsvg-convert renders SVG files to various raster and vector formats. It uses the librsvg library for high-quality SVG rendering.

PARAMETERS

-o, --output file

Output file.
-f, --format format
Output format (png, pdf, ps, eps, svg).
-w, --width px
Width in pixels.
-h, --height px
Height in pixels.
-d, --dpi-x dpi
Horizontal DPI.
-p, --dpi-y dpi
Vertical DPI.
-a, --keep-aspect-ratio
Preserve aspect ratio.
-b, --background-color color
Background color.

EXAMPLES

$ # SVG to PNG
rsvg-convert icon.svg -o icon.png

# SVG to PDF
rsvg-convert -f pdf diagram.svg -o diagram.pdf

# Resize to width
rsvg-convert -w 512 logo.svg -o logo.png

# High DPI for print
rsvg-convert -d 300 -p 300 graphic.svg -o print.png

# With background
rsvg-convert -b white input.svg -o output.png

# Multiple files
rsvg-convert -f pdf *.svg -o combined.pdf
copy

CAVEATS

Not all SVG features supported. Part of librsvg. For complex SVGs, consider Inkscape.

HISTORY

rsvg-convert is part of librsvg by the GNOME Project, originally by Raph Levien, for SVG rendering.

SEE ALSO

Copied to clipboard