Skip to main content

Crate cink

Crate cink 

Source
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§

DecodedImage
Recognized image bytes plus intrinsic dimensions when the format carries them (SVG passes through dimension-less). Pixels are not decoded or validated.

Enums§

ImageMime
Image formats normalize accepts.

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 #image call for a sized signature. Width is emitted only when a max-width clamp applied (see signature_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 ;base64 flag. Returns None for 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 None when 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.