pub fn print(img: &DynamicImage, config: &Config) -> ViuResult<(u32, u32)>
Expand description
Default printing method. Uses either iTerm or Kitty graphics protocol, if supported, and half blocks otherwise.
Check the Config struct for all customization options.
Example
The snippet below reads all of stdin, decodes it with the image
crate
and prints it to the terminal. The image will also be resized to fit in the terminal.
use std::io::{stdin, Read};
use viuer::{Config, print};
let stdin = stdin();
let mut handle = stdin.lock();
let mut buf: Vec<u8> = Vec::new();
let _ = handle
.read_to_end(&mut buf)
.expect("Could not read until EOF.");
let img = image::load_from_memory(&buf).expect("Data from stdin could not be decoded.");
print(&img, &Config::default()).expect("Image printing failed.");