1 unstable release

0.1.0 May 7, 2023

#814 in #tui

MIT license

110KB
197 lines

iterm2img

Crate Status docs.rs

Rust library for iTerm2 Inline Images Protocol

Usage

let encoded = iterm2img::from_bytes(bytes)
    .width(5)
    .inline(true)
    .build();

println("{}", encoded);

See examples/main.rs for full code.

Running this on iTerm2 gives the following:

License

MIT


lib.rs:

Build iTerm2 Inline Images Protocol string

Examples

let bytes = "abcdefg".as_bytes().to_vec();
let result = iterm2img::from_bytes(bytes)
    .name("xyz".to_string())
    .width(100)
    .height(200)
    .preserve_aspect_ratio(false)
    .inline(true)
    .build();

let expected =  "\x1b]1337;File=size=7;name=xyz;width=100;height=200;preserve_aspect_ratio=0;inline=1:YWJjZGVmZw==\u{0007}";
assert_eq!(result, expected);

Dependencies

~230KB