Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atanunq/viuer
Rust library for displaying images in the terminal.
https://github.com/atanunq/viuer
image rust terminal
Last synced: 7 days ago
JSON representation
Rust library for displaying images in the terminal.
- Host: GitHub
- URL: https://github.com/atanunq/viuer
- Owner: atanunq
- License: mit
- Created: 2020-09-15T20:23:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-12-22T14:34:28.000Z (18 days ago)
- Last Synced: 2024-12-26T12:03:49.670Z (14 days ago)
- Topics: image, rust, terminal
- Language: Rust
- Homepage:
- Size: 181 KB
- Stars: 264
- Watchers: 7
- Forks: 49
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# `viuer`
![ci](https://github.com/atanunq/viuer/actions/workflows/ci.yml/badge.svg)
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:- [Kitty](https://sw.kovidgoyal.net/kitty/graphics-protocol.html)
- [iTerm](https://iterm2.com/documentation-images.html)
- [Sixel](https://github.com/saitoha/libsixel) (behind the `sixel`
feature gate)For a demo of the library's usage and example screenshots, see
[`viu`](https://github.com/atanunq/viu?tab=readme-ov-file#examples).## Usage
With the default features, only [image::DynamicImage](https://docs.rs/image/latest/image/enum.DynamicImage.html) can be printed:
```rust
use viuer::{print, Config};let conf = Config {
// Start from row 4 and column 20.
x: 20,
y: 4,
..Default::default()
};let img = image::DynamicImage::ImageRgba8(image::RgbaImage::new(20, 10));
print(&img, &conf).expect("Image printing failed.");
```And with the `print-file` feature, `viuer` can work with files, too:
```rust
use viuer::{print_from_file, Config};let conf = Config {
// Set dimensions.
width: Some(80),
height: Some(25),
..Default::default()
};// Display `img.jpg` with dimensions 80×25 in terminal cells.
// The image resolution will be 80×50 because each cell contains two pixels.
print_from_file("img.jpg", &conf).expect("Image printing failed.");
```## Docs
Find all the configuration options in the [full documentation](https://docs.rs/viuer/latest/viuer/).