Skip to main content

Crate gifterm

Crate gifterm 

Source
Expand description

§gifterm

Play GIF animations in kitty-protocol terminals.

This crate provides the core logic for decoding GIF files, caching decoded frames, and transmitting them via the kitty graphics protocol.

§Library usage

use std::path::Path;

let path = Path::new("animation.gif");
let (meta, frames) = gifterm::load_frames(path, Some(400)).unwrap();
gifterm::play(&meta, &frames).unwrap();

§Feature flags

  • cli – Enables the clap dependency for the binary CLI. Disabled by default so the library can compile to wasm32.

Modules§

style
ANSI color codes matching the gifterm design system.

Structs§

Meta
Metadata about a decoded and cached GIF animation.

Enums§

Error
Errors that can occur during GIF decoding or playback.

Functions§

cache_dir
Return the cache directory path ($XDG_CACHE_HOME/gifterm or ~/.cache/gifterm).
cache_key
Build a cache key from the file hash and optional max width.
check_kitty_support
Check if the terminal supports the kitty graphics protocol by probing environment variables and, if needed, sending a graphics protocol query.
decode_and_cache
Decode a GIF file, optionally scale it, and write the result to the cache.
find_kitty
Find the kitty binary on disk.
gr_cmd
Build a kitty graphics protocol escape sequence.
hash_file
Compute a SHA-256 based hash of a file (first 16 hex chars).
load_frames
Load frames for a GIF, using the cache if available.
load_from_cache
Try to load previously cached frames from disk.
play
Play a decoded GIF animation via the kitty graphics protocol.
send_via_file
Transmit RGBA data to the terminal via a temp file (t=t transfer).
unique_image_id
Generate a unique image ID from current time (kitty supports u32 IDs).