kane50613/takumi
소개
헤드리스 브라우저 없이 JSX, HTML, CSS를 이미지, SVG, PDF 또는 페인트 트리로 렌더링합니다.
디자인 및 미디어What you can do
- Layout and CSS covers flexbox, CSS Grid, block, inline, table, and float layout, plus Tailwind v4 utilities, complex selectors, var(), calc(), media queries, and corner-shape.
- Typography and scripts handles Arabic shaping, bidirectional text, lang-aware CJK glyphs, emoji (with matching fonts), text-fit, text-wrap: balance and pretty, and offset-path text.
- Images and animations renders masks, clipping, blend modes, SVG filters (feTurbulence, feDisplacementMap), conic gradients, and @keyframes animations to WebP, APNG, GIF, or video frames.
- PDF documents handles page breaks, widows and orphans (default 2), repeating headers, footers, and table <thead>/<tfoot>, selectable subsetted text, bookmarks (outline: true), Factur-X attachments, and tagged PDF by default (PDF/A and PDF/UA).
측정된 스타 증가
- in 24h
- +3
- in 7 days
- +14
- in 15 days
- +23
- in 1 month
- +67
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalTakumi is a Rust layout engine whose block, inline, flexbox, grid, and table layout ports Chromium's Blink, paired with HarfRust for text shaping and Skrifa for font reading. One laid-out tree feeds four backends, so the same JSX or HTML component can render as a raster image, an SVG, a PDF, or a paint tree of resolved boxes and text runs. It runs without a headless browser on Node.js, Bun, Cloudflare Workers, browsers, and Rust.
Packages
| Package | Output | Runtime |
|---|---|---|
takumi-js (docs) |
PNG, JPEG, WebP, ICO, raw RGBA, SVG, animated WebP, APNG, GIF | Node.js, Bun (native), Workers and browsers (Wasm) |
takumi-pdf (docs) |
Paged or single-page PDF with selectable text | Node.js, Bun, Workers, and browsers (Wasm) |
takumi-paint (docs) |
Paint tree of boxes, text runs, and images with resolved CSS | Node.js, Bun, Workers, and browsers (Wasm) |
takumi (docs) |
Images, animations, and SVG from a node tree or HTML | Rust |
takumi-cli (docs) |
Images, SVG, and PDF from HTML files in allowed directories | Terminal |
Low-level bindings and helpers live in @takumi-rs/core, @takumi-rs/wasm, and @takumi-rs/helpers. See the node reference for the underlying node-tree format.
Quick Start
Install the package for your output. The examples below use Bun to run JSX directly.
bun i takumi-js # PNG, JPEG, WebP, SVG, animations
bun i takumi-pdf # paged PDF
bun i takumi-paint # paint tree
Image
Save this as image.tsx and run bun image.tsx to write a 1200 × 630 PNG.
import { render } from "takumi-js";
import { writeFile } from "node:fs/promises";
const image = await render(
<div tw="w-full h-full flex items-center justify-center bg-linear-to-b from-blue-100 to-red-50">
<h1 tw="text-6xl font-bold">Hello from Takumi</h1>
</div>,
{ width: 1200, height: 630 },
);
await writeFile("./output.png", image);
Save this as document.tsx and run bun document.tsx to write an A4 PDF with a page-number footer.
import { render } from "takumi-pdf";
import { PageNumber, TotalPages } from "takumi-pdf/primitives";
import { writeFile } from "node:fs/promises";
const pdf = await render(
<main>
<h1>Invoice</h1>
<p>Total: $1,250.00</p>
</main>,
{
size: "a4",
footer: (
<div tw="flex w-full justify-center text-[10px] text-gray-500">
Page <PageNumber /> of <TotalPages />
</div>
),
},
);
await writeFile("invoice.pdf", pdf);
Paint
Save this as paint.tsx and run bun paint.tsx to print each text run with its font.
import { paint } from "takumi-paint";
const tree = await paint(
<div style={{ width: 240, padding: 16, background: "#F7F3EC" }}>
Hello <b>world</b>
</div>,
{ width: 320 },
);
for (const node of tree.nodes) {
if (node.type !== "text") {
continue;
}
for (const run of node.runs) {
console.log(run.text, run.font.family, run.fontSize);
}
}
tree.steps lists the draws in paint order. See Drawing to replay them on a canvas.
More Examples
Google Fonts
import { render } from "takumi-js";
import { googleFonts } from "takumi-js/helpers";
const image = await render(
<div
tw="w-full h-full flex items-center justify-center"
style={{
fontSize: 72,
fontFamily: "Fraunces",
fontVariationSettings: "'opsz' 72, 'wght' 700",
}}
>
Hello from Takumi
</div>,
{
width: 1200,
height: 630,
fonts: googleFonts([{ name: "Fraunces", weight: "100..900", axes: { opsz: "9..144" } }]),
},
);
render() registers only the font subsets the content uses, and every render in the process shares the fonts it loaded. See Fonts.
API route (next/og-compatible)
import { ImageResponse } from "takumi-js/response";
export function GET() {
return new ImageResponse(
<div tw="w-full h-full flex items-center justify-center bg-linear-to-b from-blue-100 to-red-50">
<h1 tw="text-6xl font-bold">Hello from Takumi</h1>
</div>,
{ width: 1200, height: 630 },
);
}
Animated WebP
import { renderAnimation } from "takumi-js";
import { writeFile } from "node:fs/promises";
const animation = await renderAnimation({
width: 400,
height: 400,
fps: 30,
format: "webp",
scenes: [
{
durationMs: 1000,
node: (
<div tw="w-full h-full flex items-center justify-center">
<div tw="w-32 h-32 bg-blue-500 animate-spin rounded-lg" />
</div>
),
},
],
});
await writeFile("./output.webp", animation);
Vector SVG
import { renderSvg } from "takumi-js";
import { writeFile } from "node:fs/promises";
const svg = await renderSvg(
<div tw="w-full h-full flex items-center justify-center bg-linear-to-b from-blue-100 to-red-50">
<h1 tw="text-6xl font-bold">Hello from Takumi</h1>
</div>,
{ width: 1200, height: 630 },
);
await writeFile("./output.svg", svg);
Highlights
- Layout and CSS covers flexbox, CSS Grid, block, inline, table, and float layout, plus Tailwind v4 utilities, complex selectors,
var(),calc(), media queries, andcorner-shape. - Typography and scripts handles Arabic shaping, bidirectional text,
lang-aware CJK glyphs, emoji (with matching fonts),text-fit,text-wrap: balanceandpretty, andoffset-pathtext. - Images and animations renders masks, clipping, blend modes, SVG filters (
feTurbulence,feDisplacementMap), conic gradients, and@keyframesanimations to WebP, APNG, GIF, or video frames. - PDF documents handles page breaks, widows and orphans (default 2), repeating headers, footers, and table
<thead>/<tfoot>, selectable subsetted text, bookmarks (outline: true), Factur-X attachments, and tagged PDF by default (PDF/A and PDF/UA). - Runtimes ships prebuilt native bindings for Node.js and Bun (macOS, Linux glibc/musl, Windows on x64 and ARM64), WebAssembly for Cloudflare Workers and browsers (
takumi-pdfandtakumi-paintuse Wasm everywhere), and thetakumiRust crate.
Migrating & Tradeoffs
Takumi implements a subset of browser CSS and does not run page scripts. In PDF output, filter supports only color functions, so blur(), drop-shadow(), and backdrop-filter are not drawn. Keep Puppeteer or Playwright when your output depends on JavaScript execution or full browser layout, and compare your templates before switching.
| You are using | What changes |
|---|---|
satori |
Replace satori() with renderSvg(), or call render() for encoded image bytes. Compare the renderers. |
next/og |
Swap the ImageResponse import, keep explicit Flexbox styles, and compare the output. Read the migration guide. |
| Puppeteer or Playwright | Replace page.pdf() with render(). You must preload remote assets, and Takumi supports less CSS than Chrome. Read the migration guide. |
@react-pdf/renderer |
Replace Document, View, and Text with HTML elements and CSS. Browser viewers and some text controls have no equivalent. Read the migration guide. |
pdfkit |
Use JSX or HTML instead of positioning each line. Keep pdfkit when you need low-level drawing control. |
For invoice benchmarks against @react-pdf/renderer and Puppeteer, see the PDF renderer comparison.
Showcase
| Takumi OG image (source) | Package OG card (source) |
|---|---|
![]() |
![]() |
| Prisma-style API card (source) | X-style social post (source) |
![]() |
![]() |
| Keyframe Animation (source) | shiki-image |
![]() |
More examples live in example/ for invoices, e-invoices, Next.js, Cloudflare Workers, TanStack Start, Svelte, Rust, and ffmpeg keyframe animation, alongside the (Unofficial) Takumi Playground.
Used By
- Dcard renders post share images
- TanStack renders OG images for its docs
- Fumadocs generates its docs OG images
- Nuxt OG Image ships Takumi as a built-in renderer
- Luma renders event share images
- shiki-image turns syntax-highlighted code into images
See more in the showcase. Takumi is part of the Vercel OSS Program.
Contributing
Read CONTRIBUTING.md for local setup and the fixture workflow. Bug reports, feature requests, doc improvements, and new example integrations are welcome.
License
MIT or Apache-2.0. Bundled third-party code is listed in THIRD-PARTY-NOTICES.md.
관련 프로젝트 살펴보기
불러오는 중…




