Renderer¶
Renderer is the primary entry point for compilation, measurement, static rendering,
SVG, and animation.
Renderer(cache_max_bytes=...) controls each renderer's resource cache. The glyph
cache is process-wide and configured separately before first use.
takumi_py.renderer.set_glyph_cache_max_bytes ¶
Set the process-wide glyph cache budget before the first render.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_bytes
|
int
|
Maximum retained glyph-cache size in bytes. Use |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If Takumi has already initialized the glyph cache. |
takumi_py.renderer.Renderer ¶
Compile, measure, and render Takumi nodes, HTML, SVG, and animations.
__init__ ¶
__init__(
*,
load_default_fonts: bool = True,
fonts: Sequence[FontResourceInput] | None = None,
persistent_images: Sequence[ImageResourceInput]
| None = None,
cache_max_bytes: int | None = None,
) -> None
Create a renderer with optional font, image, and cache configuration.
cache_max_bytes controls the renderer-local resource cache for decoded
images, SVG rasters, and related render resources. Pass 0 to disable
retention or None to use Takumi's default budget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
load_default_fonts
|
bool
|
Load Takumi's bundled default fonts. |
True
|
fonts
|
Sequence[FontResourceInput] | None
|
Font resources to register during construction. |
None
|
persistent_images
|
Sequence[ImageResourceInput] | None
|
Deprecated renderer-wide image resources. Prefer
passing |
None
|
cache_max_bytes
|
int | None
|
Maximum renderer-local resource-cache size in bytes. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TakumiError
|
If native renderer initialization fails. |
compile_node ¶
Compile a Python node mapping for repeated rendering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
NodeInput
|
Node mapping accepted by Takumi. |
required |
validate
|
bool
|
Validate and normalize the mapping in Python before passing it to the native decoder. |
False
|
Returns:
| Type | Description |
|---|---|
CompiledNode
|
An opaque compiled node owned by the native binding. |
Raises:
| Type | Description |
|---|---|
NodeValidationError
|
If Python-side validation is enabled and fails. |
NodeDecodeError
|
If the native decoder rejects the node. |
compile_stylesheet ¶
Compile CSS and fail if it cannot be parsed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
css
|
str
|
CSS source text. |
required |
Returns:
| Type | Description |
|---|---|
CompiledStyleSheet
|
An opaque compiled stylesheet suitable for repeated rendering. |
Raises:
| Type | Description |
|---|---|
StyleSheetError
|
If the stylesheet is invalid. |
compile_stylesheet_lossy ¶
Compile CSS using Takumi's error-tolerant HTML stylesheet parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
css
|
str
|
CSS source text, potentially containing declarations that Takumi cannot parse. |
required |
Returns:
| Type | Description |
|---|---|
CompiledStyleSheet
|
A compiled stylesheet containing the declarations Takumi accepted. |
compile_keyframes ¶
Compile structured keyframe rules into a stylesheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keyframes
|
KeyframesInput
|
Keyframe mappings or rule objects accepted by Takumi. |
required |
Returns:
| Type | Description |
|---|---|
CompiledStyleSheet
|
A compiled stylesheet containing the animation rules. |
Raises:
| Type | Description |
|---|---|
StyleSheetError
|
If a keyframe rule cannot be compiled. |
register_font ¶
Register one font resource with this renderer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
font
|
FontResourceInput
|
Raw font bytes or a |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
The font-family names discovered or assigned during registration. |
Raises:
| Type | Description |
|---|---|
FontError
|
If Takumi cannot decode or register the font. |
register_fonts ¶
Register multiple font resources with this renderer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fonts
|
Sequence[FontResourceInput]
|
Raw fonts or |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
All font-family names discovered or assigned during registration. |
Raises:
| Type | Description |
|---|---|
FontError
|
If Takumi cannot decode or register a font. |
load_font ¶
Register one font without returning its family names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
font
|
FontResourceInput
|
Raw font bytes or a |
required |
Raises:
| Type | Description |
|---|---|
FontError
|
If Takumi cannot decode or register the font. |
Deprecated
Use register_font(), which returns the registered names.
load_fonts ¶
Register multiple fonts without returning their family names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fonts
|
Sequence[FontResourceInput]
|
Raw fonts or |
required |
Raises:
| Type | Description |
|---|---|
FontError
|
If Takumi cannot decode or register a font. |
Deprecated
Use register_fonts(), which returns the registered names.
put_persistent_image ¶
put_persistent_image(
resource: ImageResourceInput | str,
data: bytes | None = None,
cache: ImageCacheMode = "auto",
) -> None
Store an image resource on this renderer for later lookup by source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
ImageResourceInput | str
|
An |
required |
data
|
bytes | None
|
Image bytes when |
None
|
cache
|
ImageCacheMode
|
Native cache policy for the supplied image. |
'auto'
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ResourceError
|
If Takumi cannot decode or store the image. |
Deprecated
Pass resources through the per-render images option instead.
clear_image_store ¶
Remove all renderer-wide persistent images.
Deprecated
Pass resources through the per-render images option instead.
render_compiled ¶
render_compiled(
node: CompiledNode,
*,
stylesheets: Sequence[CompiledStyleSheet] | None = None,
keyframes: KeyframesInput | None | UnsetType = UNSET,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
format: ImageOutputFormat | UnsetType = UNSET,
quality: int | None | UnsetType = UNSET,
lossless: bool | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
device_pixel_ratio: float | UnsetType = UNSET,
draw_debug_border: bool | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
dithering: DitheringAlgorithm | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
) -> bytes
Render a compiled node to an encoded image or raw RGBA bytes.
Explicit keyword arguments override matching fields in options;
parameters left as UNSET inherit the supplied or default option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
CompiledNode
|
Previously compiled node. |
required |
stylesheets
|
Sequence[CompiledStyleSheet] | None
|
Previously compiled stylesheets applied in order. |
None
|
keyframes
|
KeyframesInput | None | UnsetType
|
Structured animation rules, |
UNSET
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
Output viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
Output viewport height, or |
UNSET
|
format
|
ImageOutputFormat | UnsetType
|
Static output format. |
UNSET
|
quality
|
int | None | UnsetType
|
Lossy encoder quality from 0 through 100 where supported. |
UNSET
|
lossless
|
bool | None | UnsetType
|
Whether to use lossless WebP encoding. |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
device_pixel_ratio
|
float | UnsetType
|
Scale factor applied to raster output dimensions. |
UNSET
|
draw_debug_border
|
bool | UnsetType
|
Draw Takumi's layout debug borders. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
dithering
|
DitheringAlgorithm | UnsetType
|
Color-dithering algorithm for formats that use it. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
Returns:
| Type | Description |
|---|---|
bytes
|
Encoded image bytes, or raw RGBA pixels when |
Raises:
| Type | Description |
|---|---|
RenderError
|
If layout or rendering fails. |
ResourceError
|
If an image resource cannot be decoded. |
UnsupportedFormatError
|
If the requested output cannot be encoded. |
ValueError
|
If an output option combination is invalid. |
measure_compiled ¶
measure_compiled(
node: CompiledNode,
*,
stylesheets: Sequence[CompiledStyleSheet] | None = None,
keyframes: KeyframesInput | None | UnsetType = UNSET,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
device_pixel_ratio: float | UnsetType = UNSET,
draw_debug_border: bool | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
dithering: DitheringAlgorithm | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
) -> MeasuredNode
Measure a compiled node without encoding an image.
Explicit keyword arguments override matching fields in options;
parameters left as UNSET inherit the supplied or default option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
CompiledNode
|
Previously compiled node. |
required |
stylesheets
|
Sequence[CompiledStyleSheet] | None
|
Previously compiled stylesheets applied in order. |
None
|
keyframes
|
KeyframesInput | None | UnsetType
|
Structured animation rules, |
UNSET
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
Layout viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
Layout viewport height, or |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
device_pixel_ratio
|
float | UnsetType
|
Scale factor used during layout. |
UNSET
|
draw_debug_border
|
bool | UnsetType
|
Enable Takumi's debug-border layout mode. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
dithering
|
DitheringAlgorithm | UnsetType
|
Dithering option passed to the native measurement context. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
Returns:
| Type | Description |
|---|---|
MeasuredNode
|
An immutable measurement tree with geometry and shaped text runs. |
Raises:
| Type | Description |
|---|---|
RenderError
|
If layout or measurement fails. |
ResourceError
|
If an image resource cannot be decoded. |
NodeDecodeError
|
If Takumi returns an invalid measurement payload. |
render_node ¶
render_node(
node: NodeInput,
*,
stylesheets: Sequence[str] | None = None,
keyframes: KeyframesInput | None = None,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
format: ImageOutputFormat | UnsetType = UNSET,
quality: int | None | UnsetType = UNSET,
lossless: bool | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
device_pixel_ratio: float | UnsetType = UNSET,
draw_debug_border: bool | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
dithering: DitheringAlgorithm | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
validate: bool = False,
) -> bytes
Compile and render a Python node mapping.
Explicit render keywords override matching fields in options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
NodeInput
|
Node mapping accepted by Takumi. |
required |
stylesheets
|
Sequence[str] | None
|
CSS source strings compiled with strict parsing. |
None
|
keyframes
|
KeyframesInput | None
|
Structured animation rules appended after |
None
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
Output viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
Output viewport height, or |
UNSET
|
format
|
ImageOutputFormat | UnsetType
|
Static output format. |
UNSET
|
quality
|
int | None | UnsetType
|
Lossy encoder quality from 0 through 100 where supported. |
UNSET
|
lossless
|
bool | None | UnsetType
|
Whether to use lossless WebP encoding. |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
device_pixel_ratio
|
float | UnsetType
|
Scale factor applied to raster output dimensions. |
UNSET
|
draw_debug_border
|
bool | UnsetType
|
Draw Takumi's layout debug borders. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
dithering
|
DitheringAlgorithm | UnsetType
|
Color-dithering algorithm for formats that use it. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
validate
|
bool
|
Validate and normalize |
False
|
Returns:
| Type | Description |
|---|---|
bytes
|
Encoded image bytes, or raw RGBA pixels when |
Raises:
| Type | Description |
|---|---|
NodeValidationError
|
If Python-side validation is enabled and fails. |
NodeDecodeError
|
If the native decoder rejects the node. |
StyleSheetError
|
If a stylesheet or keyframe rule is invalid. |
RenderError
|
If layout or rendering fails. |
UnsupportedFormatError
|
If the requested output cannot be encoded. |
measure_node ¶
measure_node(
node: NodeInput,
*,
stylesheets: Sequence[str] | None = None,
keyframes: KeyframesInput | None = None,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
device_pixel_ratio: float | UnsetType = UNSET,
draw_debug_border: bool | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
dithering: DitheringAlgorithm | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
validate: bool = False,
) -> MeasuredNode
Compile and measure a Python node mapping without encoding an image.
Explicit render keywords override matching fields in options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
NodeInput
|
Node mapping accepted by Takumi. |
required |
stylesheets
|
Sequence[str] | None
|
CSS source strings compiled with strict parsing. |
None
|
keyframes
|
KeyframesInput | None
|
Structured animation rules appended after |
None
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
Layout viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
Layout viewport height, or |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
device_pixel_ratio
|
float | UnsetType
|
Scale factor used during layout. |
UNSET
|
draw_debug_border
|
bool | UnsetType
|
Enable Takumi's debug-border layout mode. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
dithering
|
DitheringAlgorithm | UnsetType
|
Dithering option passed to the native measurement context. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
validate
|
bool
|
Validate and normalize |
False
|
Returns:
| Type | Description |
|---|---|
MeasuredNode
|
An immutable measurement tree with geometry and shaped text runs. |
Raises:
| Type | Description |
|---|---|
NodeValidationError
|
If Python-side validation is enabled and fails. |
NodeDecodeError
|
If node decoding or measurement conversion fails. |
StyleSheetError
|
If a stylesheet or keyframe rule is invalid. |
RenderError
|
If layout or measurement fails. |
compile_html ¶
Parse HTML into a compiled Takumi node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
HTML fragment or document source. |
required |
html_options
|
HtmlOptions | None
|
Parser presets, Tailwind attribute name, and maximum
element depth. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
CompiledHtml
|
The compiled root node and any stylesheets extracted during parsing. |
Raises:
| Type | Description |
|---|---|
HtmlParseError
|
If the HTML cannot be parsed or exceeds configured limits. |
render_html ¶
render_html(
html: str,
*,
stylesheets: Sequence[str] | None = None,
keyframes: KeyframesInput | None = None,
html_options: HtmlOptions | None = None,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
format: ImageOutputFormat | UnsetType = UNSET,
quality: int | None | UnsetType = UNSET,
lossless: bool | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
device_pixel_ratio: float | UnsetType = UNSET,
draw_debug_border: bool | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
dithering: DitheringAlgorithm | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
) -> bytes
Parse HTML and render it to an encoded image or raw RGBA bytes.
External CSS uses the lossy parser appropriate for browser-authored
stylesheets. Explicit render keywords override matching fields in
options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
HTML fragment or document source. |
required |
stylesheets
|
Sequence[str] | None
|
Additional CSS source strings applied in order. |
None
|
keyframes
|
KeyframesInput | None
|
Structured animation rules appended after |
None
|
html_options
|
HtmlOptions | None
|
HTML parsing configuration. |
None
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
Output viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
Output viewport height, or |
UNSET
|
format
|
ImageOutputFormat | UnsetType
|
Static output format. |
UNSET
|
quality
|
int | None | UnsetType
|
Lossy encoder quality from 0 through 100 where supported. |
UNSET
|
lossless
|
bool | None | UnsetType
|
Whether to use lossless WebP encoding. |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
device_pixel_ratio
|
float | UnsetType
|
Scale factor applied to raster output dimensions. |
UNSET
|
draw_debug_border
|
bool | UnsetType
|
Draw Takumi's layout debug borders. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
dithering
|
DitheringAlgorithm | UnsetType
|
Color-dithering algorithm for formats that use it. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
Returns:
| Type | Description |
|---|---|
bytes
|
Encoded image bytes, or raw RGBA pixels when |
Raises:
| Type | Description |
|---|---|
HtmlParseError
|
If the HTML cannot be parsed. |
StyleSheetError
|
If structured keyframes cannot be compiled. |
RenderError
|
If layout or rendering fails. |
UnsupportedFormatError
|
If the requested output cannot be encoded. |
measure_html ¶
measure_html(
html: str,
*,
stylesheets: Sequence[str] | None = None,
keyframes: KeyframesInput | None = None,
html_options: HtmlOptions | None = None,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
device_pixel_ratio: float | UnsetType = UNSET,
draw_debug_border: bool | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
dithering: DitheringAlgorithm | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
) -> MeasuredNode
Parse and measure HTML without encoding an image.
External CSS uses the lossy parser appropriate for browser-authored
stylesheets. Explicit render keywords override matching fields in
options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
HTML fragment or document source. |
required |
stylesheets
|
Sequence[str] | None
|
Additional CSS source strings applied in order. |
None
|
keyframes
|
KeyframesInput | None
|
Structured animation rules appended after |
None
|
html_options
|
HtmlOptions | None
|
HTML parsing configuration. |
None
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
Layout viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
Layout viewport height, or |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
device_pixel_ratio
|
float | UnsetType
|
Scale factor used during layout. |
UNSET
|
draw_debug_border
|
bool | UnsetType
|
Enable Takumi's debug-border layout mode. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
dithering
|
DitheringAlgorithm | UnsetType
|
Dithering option passed to the native measurement context. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
Returns:
| Type | Description |
|---|---|
MeasuredNode
|
An immutable measurement tree with geometry and shaped text runs. |
Raises:
| Type | Description |
|---|---|
HtmlParseError
|
If the HTML cannot be parsed. |
StyleSheetError
|
If structured keyframes cannot be compiled. |
RenderError
|
If layout or measurement fails. |
NodeDecodeError
|
If Takumi returns an invalid measurement payload. |
render_template ¶
render_template(
template_name: str,
context: Mapping[str, object],
*,
template_dir: str | Path = ".",
stylesheets: Sequence[str] | None = None,
keyframes: KeyframesInput | None = None,
html_options: HtmlOptions | None = None,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
format: ImageOutputFormat | UnsetType = UNSET,
quality: int | None | UnsetType = UNSET,
lossless: bool | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
device_pixel_ratio: float | UnsetType = UNSET,
draw_debug_border: bool | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
dithering: DitheringAlgorithm | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
) -> bytes
Render a Jinja template through the HTML pipeline.
Templates are loaded from template_dir using Jinja's standard
filesystem loader and autoescaping rules. Explicit render keywords override
matching fields in options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_name
|
str
|
Template path relative to |
required |
context
|
Mapping[str, object]
|
Values exposed to the Jinja template. |
required |
template_dir
|
str | Path
|
Root directory used to load templates. |
'.'
|
stylesheets
|
Sequence[str] | None
|
Additional CSS source strings applied in order. |
None
|
keyframes
|
KeyframesInput | None
|
Structured animation rules appended after |
None
|
html_options
|
HtmlOptions | None
|
HTML parsing configuration. |
None
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
Output viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
Output viewport height, or |
UNSET
|
format
|
ImageOutputFormat | UnsetType
|
Static output format. |
UNSET
|
quality
|
int | None | UnsetType
|
Lossy encoder quality from 0 through 100 where supported. |
UNSET
|
lossless
|
bool | None | UnsetType
|
Whether to use lossless WebP encoding. |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
device_pixel_ratio
|
float | UnsetType
|
Scale factor applied to raster output dimensions. |
UNSET
|
draw_debug_border
|
bool | UnsetType
|
Draw Takumi's layout debug borders. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
dithering
|
DitheringAlgorithm | UnsetType
|
Color-dithering algorithm for formats that use it. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
Returns:
| Type | Description |
|---|---|
bytes
|
Encoded image bytes, or raw RGBA pixels when |
Raises:
| Type | Description |
|---|---|
TemplateError
|
If Jinja cannot load or render the template. |
HtmlParseError
|
If the rendered HTML cannot be parsed. |
RenderError
|
If layout or rendering fails. |
UnsupportedFormatError
|
If the requested output cannot be encoded. |
render_svg_compiled ¶
render_svg_compiled(
node: CompiledNode,
*,
stylesheets: Sequence[CompiledStyleSheet] | None = None,
keyframes: KeyframesInput | None | UnsetType = UNSET,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
) -> str
Render a compiled node as an SVG document.
Explicit keyword arguments override matching fields in options;
raster-only options in RenderOptions are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
CompiledNode
|
Previously compiled node. |
required |
stylesheets
|
Sequence[CompiledStyleSheet] | None
|
Previously compiled stylesheets applied in order. |
None
|
keyframes
|
KeyframesInput | None | UnsetType
|
Structured animation rules, |
UNSET
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
SVG viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
SVG viewport height, or |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
Returns:
| Type | Description |
|---|---|
str
|
A complete SVG document as Unicode text. |
Raises:
| Type | Description |
|---|---|
RenderError
|
If layout or SVG generation fails. |
ResourceError
|
If an image resource cannot be decoded. |
render_svg_node ¶
render_svg_node(
node: NodeInput,
*,
stylesheets: Sequence[str] | None = None,
keyframes: KeyframesInput | None = None,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
validate: bool = False,
) -> str
Compile a Python node mapping and render it as SVG.
Explicit render keywords override matching fields in options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
NodeInput
|
Node mapping accepted by Takumi. |
required |
stylesheets
|
Sequence[str] | None
|
CSS source strings compiled with strict parsing. |
None
|
keyframes
|
KeyframesInput | None
|
Structured animation rules appended after |
None
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
SVG viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
SVG viewport height, or |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
validate
|
bool
|
Validate and normalize |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A complete SVG document as Unicode text. |
Raises:
| Type | Description |
|---|---|
NodeValidationError
|
If Python-side validation is enabled and fails. |
NodeDecodeError
|
If the native decoder rejects the node. |
StyleSheetError
|
If a stylesheet or keyframe rule is invalid. |
RenderError
|
If layout or SVG generation fails. |
render_svg_html ¶
render_svg_html(
html: str,
*,
stylesheets: Sequence[str] | None = None,
keyframes: KeyframesInput | None = None,
html_options: HtmlOptions | None = None,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
) -> str
Parse HTML and render it as an SVG document.
External CSS uses the lossy parser appropriate for browser-authored
stylesheets. Explicit render keywords override matching fields in
options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
HTML fragment or document source. |
required |
stylesheets
|
Sequence[str] | None
|
Additional CSS source strings applied in order. |
None
|
keyframes
|
KeyframesInput | None
|
Structured animation rules appended after |
None
|
html_options
|
HtmlOptions | None
|
HTML parsing configuration. |
None
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
SVG viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
SVG viewport height, or |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
Returns:
| Type | Description |
|---|---|
str
|
A complete SVG document as Unicode text. |
Raises:
| Type | Description |
|---|---|
HtmlParseError
|
If the HTML cannot be parsed. |
StyleSheetError
|
If structured keyframes cannot be compiled. |
RenderError
|
If layout or SVG generation fails. |
render_svg_template ¶
render_svg_template(
template_name: str,
context: Mapping[str, object],
*,
template_dir: str | Path = ".",
stylesheets: Sequence[str] | None = None,
keyframes: KeyframesInput | None = None,
html_options: HtmlOptions | None = None,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
time_ms: int | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
) -> str
Render a Jinja template as an SVG document through the HTML pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_name
|
str
|
Template path relative to |
required |
context
|
Mapping[str, object]
|
Values exposed to the Jinja template. |
required |
template_dir
|
str | Path
|
Root directory used to load templates. |
'.'
|
stylesheets
|
Sequence[str] | None
|
Additional CSS source strings applied in order. |
None
|
keyframes
|
KeyframesInput | None
|
Structured animation rules appended after |
None
|
html_options
|
HtmlOptions | None
|
HTML parsing configuration. |
None
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
SVG viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
SVG viewport height, or |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
time_ms
|
int | UnsetType
|
Animation sampling time in milliseconds. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
Returns:
| Type | Description |
|---|---|
str
|
A complete SVG document as Unicode text. |
Raises:
| Type | Description |
|---|---|
TemplateError
|
If Jinja cannot load or render the template. |
HtmlParseError
|
If the rendered HTML cannot be parsed. |
RenderError
|
If layout or SVG generation fails. |
render_sequence_at_time ¶
render_sequence_at_time(
scenes: Sequence[AnimationScene],
time_ms: int,
*,
stylesheets: Sequence[str] | None = None,
keyframes: KeyframesInput | None = None,
options: RenderOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
format: ImageOutputFormat | UnsetType = UNSET,
quality: int | None | UnsetType = UNSET,
lossless: bool | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
device_pixel_ratio: float | UnsetType = UNSET,
draw_debug_border: bool | UnsetType = UNSET,
dithering: DitheringAlgorithm | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
validate: bool = False,
) -> bytes
Render the active scene in a timed sequence at one instant.
Scene durations define the sequence timeline. Explicit render keywords
override matching fields in options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenes
|
Sequence[AnimationScene]
|
Ordered nodes and their durations in milliseconds. Nodes may already be compiled. |
required |
time_ms
|
int
|
Sequence sampling time in milliseconds. |
required |
stylesheets
|
Sequence[str] | None
|
CSS source strings compiled with strict parsing. |
None
|
keyframes
|
KeyframesInput | None
|
Structured animation rules appended after |
None
|
options
|
RenderOptions | None
|
Base render configuration. |
None
|
width
|
int | None | UnsetType
|
Output viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
Output viewport height, or |
UNSET
|
format
|
ImageOutputFormat | UnsetType
|
Static output format. |
UNSET
|
quality
|
int | None | UnsetType
|
Lossy encoder quality from 0 through 100 where supported. |
UNSET
|
lossless
|
bool | None | UnsetType
|
Whether to use lossless WebP encoding. |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
device_pixel_ratio
|
float | UnsetType
|
Scale factor applied to raster output dimensions. |
UNSET
|
draw_debug_border
|
bool | UnsetType
|
Draw Takumi's layout debug borders. |
UNSET
|
dithering
|
DitheringAlgorithm | UnsetType
|
Color-dithering algorithm for formats that use it. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
validate
|
bool
|
Validate and normalize uncompiled scene nodes in Python. |
False
|
Returns:
| Type | Description |
|---|---|
bytes
|
Encoded image bytes, or raw RGBA pixels when |
Raises:
| Type | Description |
|---|---|
AnimationError
|
If the sequence is empty or its timeline is invalid. |
NodeValidationError
|
If Python-side validation is enabled and fails. |
NodeDecodeError
|
If a native node decoder rejects a scene. |
RenderError
|
If layout or rendering fails. |
UnsupportedFormatError
|
If the requested output cannot be encoded. |
render_animation ¶
render_animation(
scenes: Sequence[AnimationScene],
*,
stylesheets: Sequence[str] | None = None,
keyframes: KeyframesInput | None = None,
options: RenderOptions | None = None,
encode_options: AnimationEncodeOptions | None = None,
width: int | None | UnsetType = UNSET,
height: int | None | UnsetType = UNSET,
font_size: float | UnsetType = UNSET,
device_pixel_ratio: float | UnsetType = UNSET,
draw_debug_border: bool | UnsetType = UNSET,
dithering: DitheringAlgorithm | UnsetType = UNSET,
images: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
font_families: Sequence[str] | None | UnsetType = UNSET,
lang: str | None | UnsetType = UNSET,
fetched_resources: Sequence[ImageResourceInput]
| None
| UnsetType = UNSET,
fps: int = 30,
format: AnimationOutputFormat | UnsetType = UNSET,
quality: int | None | UnsetType = UNSET,
lossless: bool | None | UnsetType = UNSET,
loop_count: int | None | UnsetType = UNSET,
webp_blend: bool | UnsetType = UNSET,
webp_dispose: bool | UnsetType = UNSET,
webp_speed: int | None | UnsetType = UNSET,
validate: bool = False,
) -> bytes
Render a timed scene sequence and encode it as an animation.
Render keywords override fields in options. Encoder keywords override
fields in encode_options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenes
|
Sequence[AnimationScene]
|
Ordered nodes and their durations in milliseconds. Nodes may already be compiled. |
required |
stylesheets
|
Sequence[str] | None
|
CSS source strings compiled with strict parsing. |
None
|
keyframes
|
KeyframesInput | None
|
Structured animation rules appended after |
None
|
options
|
RenderOptions | None
|
Base render configuration shared by every frame. |
None
|
encode_options
|
AnimationEncodeOptions | None
|
Base animation encoder configuration. |
None
|
width
|
int | None | UnsetType
|
Output viewport width, or |
UNSET
|
height
|
int | None | UnsetType
|
Output viewport height, or |
UNSET
|
font_size
|
float | UnsetType
|
Root font size in CSS pixels. |
UNSET
|
device_pixel_ratio
|
float | UnsetType
|
Scale factor applied to frame dimensions. |
UNSET
|
draw_debug_border
|
bool | UnsetType
|
Draw Takumi's layout debug borders. |
UNSET
|
dithering
|
DitheringAlgorithm | UnsetType
|
Color-dithering algorithm for formats that use it. |
UNSET
|
images
|
Sequence[ImageResourceInput] | None | UnsetType
|
Per-render image resources addressable by their |
UNSET
|
font_families
|
Sequence[str] | None | UnsetType
|
Preferred fallback font-family order. |
UNSET
|
lang
|
str | None | UnsetType
|
Document language used for text shaping and font selection. |
UNSET
|
fetched_resources
|
Sequence[ImageResourceInput] | None | UnsetType
|
Deprecated alias for externally fetched images. |
UNSET
|
fps
|
int
|
Number of frames rendered per second. |
30
|
format
|
AnimationOutputFormat | UnsetType
|
Animation container format. |
UNSET
|
quality
|
int | None | UnsetType
|
Lossy encoder quality from 0 through 100 where supported. |
UNSET
|
lossless
|
bool | None | UnsetType
|
Whether to use lossless WebP encoding. |
UNSET
|
loop_count
|
int | None | UnsetType
|
Number of animation repetitions, or |
UNSET
|
webp_blend
|
bool | UnsetType
|
Blend each WebP frame with the previous canvas. |
UNSET
|
webp_dispose
|
bool | UnsetType
|
Dispose each WebP frame before drawing the next one. |
UNSET
|
webp_speed
|
int | None | UnsetType
|
WebP encoder speed/effort setting supported by Takumi. |
UNSET
|
validate
|
bool
|
Validate and normalize uncompiled scene nodes in Python. |
False
|
Returns:
| Type | Description |
|---|---|
bytes
|
Encoded WebP, APNG, or GIF animation bytes. |
Raises:
| Type | Description |
|---|---|
AnimationError
|
If the timeline or encoder configuration is invalid. |
NodeValidationError
|
If Python-side validation is enabled and fails. |
NodeDecodeError
|
If a native node decoder rejects a scene. |
RenderError
|
If layout or frame rendering fails. |
UnsupportedFormatError
|
If the animation cannot be encoded. |
encode_frames ¶
encode_frames(
frames: Sequence[RawAnimationFrame],
*,
encode_options: AnimationEncodeOptions | None = None,
format: AnimationOutputFormat | UnsetType = UNSET,
quality: int | None | UnsetType = UNSET,
lossless: bool | None | UnsetType = UNSET,
loop_count: int | None | UnsetType = UNSET,
webp_blend: bool | UnsetType = UNSET,
webp_dispose: bool | UnsetType = UNSET,
webp_speed: int | None | UnsetType = UNSET,
) -> bytes
Encode pre-rendered raw RGBA frames as an animation.
Explicit encoder keywords override matching fields in encode_options.
Each frame's byte length must equal width * height * 4.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
Sequence[RawAnimationFrame]
|
Ordered raw RGBA frames with dimensions and durations. |
required |
encode_options
|
AnimationEncodeOptions | None
|
Base animation encoder configuration. |
None
|
format
|
AnimationOutputFormat | UnsetType
|
Animation container format. |
UNSET
|
quality
|
int | None | UnsetType
|
Lossy encoder quality from 0 through 100 where supported. |
UNSET
|
lossless
|
bool | None | UnsetType
|
Whether to use lossless WebP encoding. |
UNSET
|
loop_count
|
int | None | UnsetType
|
Number of animation repetitions, or |
UNSET
|
webp_blend
|
bool | UnsetType
|
Blend each WebP frame with the previous canvas. |
UNSET
|
webp_dispose
|
bool | UnsetType
|
Dispose each WebP frame before drawing the next one. |
UNSET
|
webp_speed
|
int | None | UnsetType
|
WebP encoder speed/effort setting supported by Takumi. |
UNSET
|
Returns:
| Type | Description |
|---|---|
bytes
|
Encoded WebP, APNG, or GIF animation bytes. |
Raises:
| Type | Description |
|---|---|
AnimationError
|
If the frames have invalid dimensions or byte lengths, or the encoder configuration is invalid. |
UnsupportedFormatError
|
If the animation cannot be encoded. |