Skip to content
Cythonic wrapper around nanosvg for rasterizing SVGs
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
nanosvg @ 25241c5 Update nanosvg Apr 23, 2019
svg-stubs Update stub package Jun 7, 2018
svg Add __init__.c Jul 7, 2018
tests Fix path issue in tests Nov 26, 2017
.appveyor.yml Use cibuildwheel to build wheels Jul 7, 2018
.gitignore Update stub package Jun 7, 2018
.gitmodules Initial commit Nov 16, 2017
.travis.yml update pip on travis Apr 23, 2019
LICENSE Add LICENSE, update README, provide c file Nov 24, 2017 Add headers to build Jun 27, 2018 Update README Apr 23, 2019
pyproject.toml Update for PEP 517 Apr 23, 2019
pytest.ini Root dir should be tests/ Nov 17, 2017 Use cibuildwheel to build wheels Jul 7, 2018


NOTE: nanosvg is no longer actively maintained

Travis | AppVeyor

Pynanosvg is a wrapper around nanosvg a simple svg parsing library. I created pynanosvg because the only other options in Python were the librsvg bindings, which are very large!



git clone --recursive
cd pynanosvg
python3 -m pip install .

or just

python3 -m pip install pynanosvg


The following parses an SVG file, rasterizes it, and saves it as a PNG

# import things
from svg import Parser, Rasterizer, SVG
from PIL import Image  # for saving rasterized image
# Parse from a file
svg = Parser.parse_file('my_cool_img.svg')
print('Image is {} by {}.'.format(svg.width, svg.height))
rast = Rasterizer()
buff = rast.rasterize(svg, svg.width, svg.height)
im = Image.frombytes('RGBA', svg.width, svg.height, buff)'my_cool_img.png')  # save the converted image!
You can’t perform that action at this time.