CLI Reference
Usage
java -jar jairosvg-cli.jar [OPTIONS] INPUT
Where INPUT is a path to an SVG file or a URL.
Options
| Option | Short | Description | Default |
|---|---|---|---|
--output FILE |
-o |
Output filename | stdout |
--format FORMAT |
-f |
Output format: png, jpeg, tiff, pdf, ps, eps |
png |
--dpi DPI |
-d |
Resolution in dots per inch | 96 |
--scale FACTOR |
-s |
Scale factor | 1 |
--background COLOR |
-b |
Background color (name, hex, rgb) | transparent |
--width PIXELS |
-W |
Parent container width | — |
--height PIXELS |
-H |
Parent container height | — |
--output-width PX |
Desired output width | — | |
--output-height PX |
Desired output height | — | |
--negate-colors |
-n |
Negate (invert) vector colors | off |
--unsafe |
-u |
Allow external file access and XML entities | off |
--version |
Print version and exit | ||
--help |
-h |
Print help and exit |
Examples
Basic conversion
# SVG to PNG
java -jar jairosvg-cli.jar logo.svg -o logo.png
# SVG to PDF
java -jar jairosvg-cli.jar diagram.svg -f pdf -o diagram.pdf
# SVG to JPEG
java -jar jairosvg-cli.jar photo.svg -f jpeg -o photo.jpg
Scaling and DPI
# 2x scale for retina displays
java -jar jairosvg-cli.jar icon.svg -s 2 -o icon@2x.png
# High DPI output
java -jar jairosvg-cli.jar chart.svg -d 300 -o chart-print.png
Background and colors
# White background
java -jar jairosvg-cli.jar logo.svg -b white -o logo-white.png
# Dark mode (negate colors)
java -jar jairosvg-cli.jar logo.svg -n -o logo-dark.png
From URL
java -jar jairosvg-cli.jar https://example.com/image.svg -o output.png
Output to stdout (pipe)
java -jar jairosvg-cli.jar input.svg | display
Using JBang
# Install JairoSVG to local Maven repo first
./mvnw install -DskipTests
# Run via JBang catalog
jbang jairosvg@brunoborges input.svg -o output.png
