Updated
On this page
Output generator: converts SVG content to various file formats.
#predraw.output
#predraw.output
Output generator: converts SVG content to various file formats.
#write_outputs
python
def write_outputs(svg_content: str, config: dict, output_dir: str) -> list[str]Write all outputs defined in config, returning list of written file paths.
config is the parsed config.json dict with an "outputs" list like: [ {"format": "svg", "path": "out/social.svg"}, {"format": "png", "path": "out/social.png"}, {"format": "webp", "path": "out/social.webp", "quality": 90} ]
output_dir is the base directory for resolving relative paths.
#_write_svg
python
def _write_svg(svg_content: str, path: str) -> NoneWrite SVG string to file.
#_write_png
python
def _write_png(svg_content: str, path: str) -> NoneConvert SVG to PNG using cairosvg and write to file.
#_write_webp
python
def _write_webp(svg_content: str, path: str, quality: int=90) -> NoneConvert SVG to PNG via cairosvg, then convert to WebP via Pillow.