Skip to content

takumi-py

Python 3.11+ bindings for the Takumi Rust renderer. Turn typed node trees, HTML, or Jinja templates into raster images, SVG, and animation without a browser runtime.

Get started API reference

Choose your path

  • Render your first image


    Install the wheel and create a PNG from HTML in a few lines.

    Quickstart

  • Understand rendering


    Choose between node trees, HTML, and compiled content, then pick raster, SVG, or measurement output.

    Rendering model · HTML and CSS · Output formats

  • Manage resources


    Register fonts, provide in-memory images, and control language-aware shaping.

    Fonts and images

  • Build dynamic output


    Render Jinja templates or encode WebP, APNG, and GIF animations.

    Templates · Animation

Minimal example

from pathlib import Path

from takumi_py import Renderer

png = Renderer().render_html(
    '<main class="card">Hello from Python</main>',
    stylesheets=[
        """
        .card {
          width: 1200px;
          height: 630px;
          display: flex;
          align-items: center;
          justify-content: center;
          color: white;
          background: #111827;
          font-size: 72px;
        }
        """
    ],  # (1)!
    width=1200,
    height=630,  # (2)!
)

Path("out.png").write_bytes(png)
  1. Document-level CSS is an explicit input. Inline style attributes remain part of the HTML input.
  2. An explicit viewport makes output dimensions deterministic. Either dimension can also be inferred from layout.

Design boundary

The binding exposes practical Takumi core capabilities while keeping resource ownership explicit: callers provide external fonts and image bytes, and the renderer does not access the network. The package intentionally has no Playwright fallback, remote fetcher, AbortSignal abstraction, data URL helper, or Node.js sidecar. See the complete support matrix.