sixel-bytes

Screenshot

Encode an image with [sixel-sys].

This is my first crate that uses unsafe and FFI. Please inspect the source code yourself, the crate is very small. PRs are welcome.

To write a sixel to a file, [sixel-rs] is probably safer and has more options.

Examples

Encode a generated image to sixel and print it: ```rust let mut bytes: Vec = Vec::new(); for x in 0..255 { for y in 0..255 { bytes.append(&mut vec![x, 0, y]); } }

let data = sixelbytes::sixelstring( &bytes, 255, 255, sixelbytes::PixelFormat::RGB888, sixelbytes::DiffusionMethod::Atkinson, ).unwrap(); assert_eq!(&data[..3], "\u{1b}Pq"); ```

Encode an image from the [image] crate to sixel and print it: ```rust let image = image::io::Reader::open("./assets/Ada.png") .unwrap() .decode() .unwrap() .intorgba8(); let bytes = image.asraw();

match sixelbytes::sixelstring( bytes, image.width() as , image.height() as _, sixelbytes::PixelFormat::RGBA8888, sixel_sys::DiffusionMethod::Stucki, ) { Err(err) => eprintln!("{err}"), Ok(data) => print!("{data}"), } ```

Binaries

sixel <path/to/image> uses the [image] crate to load an image with supported formats, convert to RGBA8888, encode to sixel, and dump the resulting string to stdout. It must be built with the image feature.

test-sixel just generates some 255x255 image with a gradient and dumps it to stdout.

Features

The image feature is disabled by default but needed for the sixel binary.

Current version: 0.2.0

License: MIT