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 theclapdependency for the binary CLI. Disabled by default so the library can compile towasm32.
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/giftermor~/.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=ttransfer). - unique_
image_ id - Generate a unique image ID from current time (kitty supports u32 IDs).