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.
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.
-
Understand rendering
Choose between node trees, HTML, compiled content, raster output, and SVG.
-
Manage resources
Register fonts, provide in-memory images, and control language-aware shaping.
-
Build dynamic output
Render Jinja templates or encode WebP, APNG, and GIF animations.
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)
- Document-level CSS is an explicit input. Inline
styleattributes remain part of the HTML input. - 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.