Skip to main content

Module process

Module process 

Source
Expand description

Sniff, decode and derive the two files an attachment needs besides its original: a small thumbnail for the composer and transcript, and the “send-copy” the agent actually receives. SPEC_AGENT_PANE_IMAGE_ATTACHMENTS_2026_09_26.md §6.4.

Everything here is synchronous and CPU-bound; callers run it on a blocking thread.

Structs§

Derived
Everything the pipeline derives from one original.
Encoded
One derived file, encoded in memory.
ProcessError
Why an image couldn’t be processed. code values are the AttachmentFailedEvent::code vocabulary.

Enums§

Sniffed
What the first bytes of a file say it is. Extensions lie (a HEIC saved as .jpg is common), so every decision below goes through this.

Constants§

MAX_PIXELS
Largest pixel count accepted before decoding.
MAX_SIDE
Largest side accepted before decoding (decompression-bomb guard).
SEND_MAX_BYTES
Upper bound on the send-copy’s size. Bedrock and Vertex cap images at 5 MB; the Anthropic API itself at 10 MB base64.
THUMB_EDGE
Long edge of the thumbnail.

Functions§

check_dimensions
decode_cost_bytes
Bytes of memory a decode of a w×h image is budgeted at: the RGBA8 frame plus one working copy (a resize or colour conversion).
derive
Decode path (already sniffed as format) and produce the thumbnail and the send-copy. send_max_edge is the send-copy’s long edge.
encode_jpeg 🔒
encode_png 🔒
encode_send_copy 🔒
encode_thumbnail 🔒
ext_of
fit 🔒
gif_is_animated 🔒
has_real_alpha 🔒
True when some pixel is not fully opaque. Many screenshots carry an alpha channel that is 255 everywhere; those can still become JPEG.
header_dimensions
Width and height from the file header, without decoding pixels. Fails with too_large_dimensions past the bomb guard.
mime_of
sniff