Skip to content

takumi-py

Python 3.10+ 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

Testing-stage project

Public APIs, exception types, and release platforms may still change as Takumi core evolves. Read the changelog before upgrading.

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, compiled content, raster output, and SVG.

    Rendering model

  • 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.