Skip to main content

encode_kitty

Function encode_kitty 

Source
pub fn encode_kitty(id: u32, data: &[u8], cols: u16, rows: u16) -> String
Expand description

Encode image data for the Kitty graphics protocol.

The payload is treated as a PNG image (f=100), base64-encoded and transmitted in chunks. q=1 suppresses terminal responses, m=0 marks the final chunk, and a trailing a=p command places the image by id.

cols and rows tell the terminal how many cells the image should occupy on screen. The image is scaled to fit that cell rectangle, which lets the layout engine reserve the matching amount of space.

Chunking follows the spec: only the first chunk carries the full set of keys (a, f, i, q, m); continuation chunks only carry q and m.