predraw v0.3.0 /predraw.output
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) -> None

Write SVG string to file.

#_write_png

python
def _write_png(svg_content: str, path: str) -> None

Convert SVG to PNG using cairosvg and write to file.

#_write_webp

python
def _write_webp(svg_content: str, path: str, quality: int=90) -> None

Convert SVG to PNG via cairosvg, then convert to WebP via Pillow.

Search