Expand description
Handwritten signature image rendering for formal correspondence.
Pixels, not signatures: this library emulates the inking process (a picture of handwriting placed on the letter). No cryptography, no identity, no legal ceremony. Supported inputs are PNG and JPEG (dimensions read from headers, never decoded) and SVG (passed through, dimensions unknown). Header recognition does not validate compressed pixels or sanitize SVG; callers must use an appropriate renderer for untrusted images. Oversized rasters are reported, never silently resampled.
Limits live as data in tables/defaults.json; tests/vectors/*.json
with fixtures in tests/fixtures/ is the executable contract every
language port runs.
Same input always yields the same output: no models, no I/O.
Structs§
- Decoded
Image - Recognized image bytes plus intrinsic dimensions when the format carries them (SVG passes through dimension-less). Pixels are not decoded or validated.
Enums§
- Image
Mime - Image formats
normalizeaccepts.
Functions§
- default_
max_ pixels - Default oversize threshold in pixels, from
tables/defaults.json. - exceeds_
limits - Whether the raster exceeds a pixel budget. Dimension-less formats (SVG) scale without loss and never exceed.
- image_
snippet - Typst
#imagecall for a sized signature. Width is emitted only when a max-width clamp applied (seesignature_size); layout and placement stay with the caller, whose line budgets they affect. - normalize
- Recognize a signature image given as a
data:URL or raw base64. Base64 must use the canonical alphabet, padding and trailing bits without whitespace. Data URLs must end their metadata with the;base64flag. ReturnsNonefor empty, undecodable, malformed-header, or unsupported inputs (including WebP and GIF). This reads raster headers only: successful recognition does not validate pixel data or sanitize SVG content. - scale_
to_ fit - Linear scale factor that fits the image into a pixel budget, never above 1.0 (never upscales). The caller resamples and re-submits.
- signature_
size - Point size for a target height, preserving aspect ratio, clamped to an
optional maximum width. Returns
Nonewhen the image carries no dimensions (SVG without explicit metrics), when dimensions or requested sizes are nonpositive/nonfinite, or when the result cannot be represented as positive finite point dimensions. The caller must handle those cases. - supported_
formats - Accepted image formats, from
tables/defaults.json.