Display images in the terminal with ease.
viuer
is a Rust library that makes it easy to show images in the terminal.
It has a straightforward interface and is configured through a single struct.
The default printing method is through lower half blocks (▄
or \u2585
).
However some custom graphics protocols are supported. They result in full
resolution images being displayed in specific environments:
Add this to Cargo.toml
:
[dependencies]
viuer = "0.8"
For a demo of the library's usage and example screenshots, see
viu
.
use viuer::{print_from_file, Config};
fn main() {
let conf = Config {
// Set offset.
x: 20,
y: 4,
// Set dimensions.
width: Some(80),
height: Some(25),
..Default::default()
};
// Starting from row 4 and column 20,
// display `img.jpg` with dimensions 80×25 (in terminal cells).
// Note that the actual resolution in the terminal will be 80×50.
print_from_file("img.jpg", &conf).expect("Image printing failed.");
}
Or if you have a DynamicImage, you can use it directly:
// ... `Config` setup
let img = image::DynamicImage::ImageRgba8(image::RgbaImage::new(20, 10));
viuer::print(&img, &conf).expect("Image printing failed.");
Check the full documentation for examples and all the configuration options.