Skip to content

aslpavel/svgrasterize.py

Repository files navigation

Python SVG rasterizer

This is very simple python+numpy SVG rasterize. It is defensively incomplete and does have bugs.

Usage

It can be used as stand alone executable to generate PNG out of SVG file.

usage: svgrasterize.py [-h] [-bg BG] [-fg FG] [-w WIDTH] [-id ID]
                       [-t TRANSFORM] [--linear-rgb]
                       [--fonts [FONTS [FONTS ...]]]
                       svg output

positional arguments:
  svg                   input SVG file
  output                output PNG file

optional arguments:
  -h, --help            show this help message and exit
  -bg BG                set default background color
  -fg FG                set default foreground color
  -w WIDTH, --width WIDTH
                        output width
  -id ID                render single element with specified `id`
  -t TRANSFORM, --transform TRANSFORM
                        apply additional transformation
  --linear-rgb          use linear RGB for rendering
  --fonts [FONTS [FONTS ...]]
                        paths to SVG files containing all fonts

Supported features:

  • anti-aliased fill/stroke path
    • with a color
    • with linear and radial gradients
    • with a pattern
  • masking and clipping
  • filters
    • feColorMatrix
    • feComposite
    • feGaussianBlur (scipy is required)
    • feMerge
    • feMorphology
    • feOffset
  • SVG fonts
  • text rendering
    • text element
    • tspan

Demo

Text

prompt

Some Icons

icons

Releases

No releases published

Packages

No packages published

Languages