Write SVG files with Python.
Project description
svg_writer
The most straightforward way to create SVG files with Python.
Three functions only:
from svg_writer import new_svg_root, write_svg, write_png_from_svg
new_svg_root
x: float,
y: float,
width: float,
height: float,
pad: float = 0
-> etree.Element
Create an svg root element from viewBox style arguments and provide the necessary svg-specific attributes. This is your window onto the scene. The arguments are the same you'd use to create a rect element (plus pad):
x: x value in upper-left cornery: y value in upper-left cornerwidth: width of viewBoxheight: height of viewBoxpad: The one small convenience I've provided. Optionally increase viewBox bypadin all directions.
write_svg
filename: str,
xml: etree.Element,
stylesheet: Optional[str] = None,
do_link_css: bool = True,
-> None:
Write an xml element as an svg file. This will link or inline your css code and insert the necessary declaration, doctype, and processing instructions.
filename: path to output file (include extension .svg)param xml: root node of your svg geometry (created bynew_svg_root)stylesheet: optional path to a css stylesheetdo_link_css: link to stylesheet, else write contents of stylesheet into svg (ignored ifstylesheetis None)
write_png_from_svg
inkscape_exe: PathType,
svg: str
-> Path
Convert an svg file to a png. Python does not have a library for this. That has an upside, as any library would be one more set of svg implementation idiosyncrasies we'd have to deal with. Inkscape will convert the file. This function provides the necessary command-line arguments.
inkscape_exe: path to inkscape.exesvg: path to svg filereturn: png filename
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file svg_writer-0.4.tar.gz.
File metadata
- Download URL: svg_writer-0.4.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9202bda5e80079486f05eab3ef99527ae061199df16f023eb68ea7ef0147c32d
|
|
| MD5 |
6db7776d6bb5d0a8f8908e48ce8f7f41
|
|
| BLAKE2b-256 |
100b63bfec9ad4d261a76011f1672b6f35b1bcbc86c648c11f0f1c44932ffd7a
|
File details
Details for the file svg_writer-0.4-py3-none-any.whl.
File metadata
- Download URL: svg_writer-0.4-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b87b54f2748a1079bd50ee788c9924a8c18aedf29f637e5a336cdb5ee6cabc8
|
|
| MD5 |
84356bf6979e5b5d0a04cd10fde8f3c1
|
|
| BLAKE2b-256 |
30cea20b27b05e9314e1de08141b457d823ccef37a9053f4f27b0f8d63ba9883
|