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.
- Process
Error - Why an image couldn’t be processed.
codevalues are theAttachmentFailedEvent::codevocabulary.
Enums§
- Sniffed
- What the first bytes of a file say it is. Extensions lie (a HEIC saved as
.jpgis 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×himage is budgeted at: the RGBA8 frame plus one working copy (a resize or colour conversion). - derive
- Decode
path(already sniffed asformat) and produce the thumbnail and the send-copy.send_max_edgeis 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_dimensionspast the bomb guard. - mime_of
- sniff