TakumiTakumi

Quick Start

The fastest and simplest way to start using Takumi.

Takumi is an image rendering engine written in Rust. The design is mainly inspired by satori, but with a focus on portability and performance (2-10x compared to next/og in Image Bench).

You can try Takumi in Playground without any installation.

Installation

The fastest/simplest way to use Takumi is with the ImageResponse API. It handles the internal state for font & image cache and it tries to be compatible with Next.js ImageResponse API.

npm i @takumi-rs/image-response

Additional Bundler Setup

Takumi offers two types of bindings for different environments. @takumi-rs/core for Node.js and @takumi-rs/wasm for WebAssembly.

Node.js Runtime

Edge Runtime / Browser

Usage

Since ImageResponse extends standard Response class, you can plug it into anywhere you want.

It comes with pre-bundled full axis (which means 100-900 weights available) Geist and Geist Mono as default fonts. Tailwind CSS is also supported out of the box.


import {  } from "@takumi-rs/image-response";
import {  } from "bun";

({
  () {
    return new (< />, {
      : 1200,
      : 630,
      : "webp",
    });
  },
});

function () {
  return (
    < ="bg-white w-full h-full flex items-center justify-center">
      < ="text-4xl font-bold">Hello</>
    </>
  );
}

import {  } from "@takumi-rs/image-response/wasm";
import {  } from "bun";

  // Check the additional bundler setup section for more details.
import  from "@takumi-rs/wasm/next";

export default {
  () {
    return new (< />, {
      : 1200,
      : 630,
      : "webp",
      ,
    });
  },
}

function () {
  return (
    < ="bg-white w-full h-full flex items-center justify-center">
      < ="text-4xl font-bold">Hello</>
    </>
  );
}

Templates

If you don't have any idea about where to start, or just want quick and easy way to get started, you can use the built-in templates.

npm i @takumi-rs/template

import  from "@takumi-rs/template/docs-template-v1";
import {  } from "@takumi-rs/image-response";
import {  } from "lucide-react";

export function () {
  return new (
    < 
      ="Hello" 
      ="World" 
      ={< />} 
      ="hsla(354, 90%, 54%, 0.3)" 
      ="hsl(354, 90%, 60%)" 
      ="Takumi" 
    />, 
    {
      : 1200,
      : 630,
      : "webp",
    },
  );
}

You can find all the templates in the takumi-template folder.

We need your help to improve and create more templates! Please feel free to submit PRs to add more templates.

Examples

Check out the example folder for different framework usages.

Learn More

Why build a satori alternative?

Takumi's focus is on how to rasterize images fast, while satori outputs SVG.

More discussion can be found in this X thread by @shuding_.

  • All in one. No need to output SVG then have resvg-js rendering it again to output PNG.
  • Inline layout support (display block or inline).
  • Tailwind CSS support out of the box.
  • RTL support.
  • Variable fonts support.
  • COLR font support (e.g. twemoji-colr).
  • WOFF2 font format support.
  • PNG, JPEG, WebP, AVIF output support.
  • WebP, APNG animation rendering support.
Edit on GitHub

Last updated on