Expand description
Library to display images in the terminal.
This library contains functionality extracted from the viu
crate.
It aims to provide an easy to use interface to print images in the terminal. Uses some abstractions
provided by the image
crate. Both the Kitty
and iTerm graphic protocols are supported.
By default, they are used if detected. If not, viuer
will fallback to using regular
half blocks instead (▄ and ▀).
Basic Usage
The example below shows how to print the image img.jpg
in 40x30 terminal cells, with vertical
offset of 4 and horizontal of 10, starting from the top left corner. More options are available
through the Config struct.
use viuer::{Config, print_from_file};
let conf = Config {
width: Some(40),
height: Some(30),
x: 10,
y: 4,
..Default::default()
};
// will resize the image to fit in 40x30 terminal cells and print it
print_from_file("img.jpg", &conf).expect("Image printing failed.");
Structs
Configuration struct to customize printing behaviour.
Enums
The extend to which the Kitty graphics protocol can be used.
Custom error enum for
viu
ing operationsFunctions
Returns the terminal’s support for the Kitty graphics protocol.
Returns the terminal’s support for the iTerm graphics protocol.
Default printing method. Uses either iTerm or Kitty graphics protocol, if supported,
and half blocks otherwise.
Helper method that reads a file, tries to decode it and prints it.
Resize a image::DynamicImage so that it fits within optional width and height bounds.
If none are provided, terminal size is used instead.
Try to get the terminal size. If unsuccessful, fallback to a default (80x24).
Type Definitions
Custom result type for error-prone operations