Skip to main content

Module image_decode

Module image_decode 

Source
Expand description

Image decoding worker.

Decodes an image file off the UI thread and turns it into a PreviewContent::Image carrying the encoder state for the terminal’s inline-image protocol. Which protocol that is, and whether pixel previews are enabled at all, is decided by crate::preview::graphics.

Decoding is the expensive part (a large JPEG can take tens of milliseconds), which is why it runs on spawn_blocking and reports back through WorkerMsg::ImageMeta tagged with the preview generation. Resizing and encoding for the pane’s current size happen later, on the UI thread, and are cached by ratatui-image until the pane changes size.

Functions§

spawn_image_decode
Decodes path off-thread, sending a WorkerMsg::ImageMeta result through tx tagged with generation.