[−][src]Crate viuer
Small 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.
Basic Usage
The example below shows how to print the image img.jpg
in 40x30 terminal cells, starting at the
top left corner. Since viuer
uses half blocks by default (▄ and ▀), it will be able to fit a
40x60 image in 40x30 cells. Options are available through the Config struct.
use viuer::{Config, print_from_file}; let conf = Config { width: Some(40), height: Some(30), ..Default::default() }; // will resize the image to fit in 40x60 terminal cells and print it print_from_file("img.jpg", &conf).expect("Image printing failed.");
Structs
Config | Configuration struct to customize printing behaviour. |
Enums
ViuError | Custom error type for |
Functions
Default printing method. Uses upper and lower half blocks to fill terminal cells. | |
print_from_file | Helper method that reads a file, tries to decode it and prints it. |
resize | Helper method that resizes a image::DynamicImage to make it fit in the terminal. |
terminal_size | Try to get the terminal size. If unsuccessful, fallback to a default (80x24). |