Generator

class img_gen.Generator(external_resource_paths: list[Path | str] | None = None, cache_root: Path | str | None = None)

A class to represent an image generator.

The given Layout describes how to generate the Image.

This struct caches the font database and font source client to avoid re-initializing them on every render() call.

render(layout: Layout) Image

Render the layout and return the Image.

class img_gen.Image

A class to represent an Image object.

This class cannot be constructed from python, rather it is returned from Generator.render()

bytes

The image data as a bytes object

save(name: Path | str) None

Save the image data to a file.

Does not support SVG output. The image format is determined from the file extension in the given name.

sha256

A hexadecimal string representing the SHA256 hash digest of the image data.