Skip to main content

Wrapper around nanosvg

Project description

pynanosvg

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!

Install

Simple:

git clone --recursive https://github.com/ethanhs/pynanosvg.git
cd pynanosvg
python3 -m pip install -r requirements.txt
python3 setup.py install

or just

python3 -m pip install pynanosvg

Usage

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)
im.save('my_cool_img.png')  # save the converted image!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynanosvg-0.3.1.tar.gz (346.0 kB view details)

Uploaded Source

File details

Details for the file pynanosvg-0.3.1.tar.gz.

File metadata

  • Download URL: pynanosvg-0.3.1.tar.gz
  • Upload date:
  • Size: 346.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pynanosvg-0.3.1.tar.gz
Algorithm Hash digest
SHA256 5e1a211d8778bf26c11d909b6905eff7822eea0abceda5eb294d5f6051f747d6
MD5 747e5a989dc6c36762c676f924b74331
BLAKE2b-256 f5c44488d5fd0798ac944effd4a0aab7e3e1b2a6e01816e6df850866970a2217

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page