img-gen documentation

This python package (img_gen) generates images. It is written in rust to encapsulate SVG support without needing external dependencies (like cairo) installed.

This library has 2 parts:

  1. The Layout specification (img-gen-spec) which defines the data structures for generating images.

  2. The Generator (img-gen-renderer) which takes the specification and renders an image.

Most of this documentation focuses on the specification because the rendering API is rather straight forward.

import asyncio
from img_gen import Generator, Layout, Debug

async def main():
    # Define the layout of the image
    layout = Layout(
        # nothing fancy, just an empty layout with debug outlines drawn
        debug=Debug(enable=True),
    )

    # Create a generator
    generator = Generator()
    # Generate the image
    image = await generator.render(layout)

    # Save the image to a file
    image.save(f"{image.sha256}.png")