-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for proper alpha blending, limited & updated dependenci…
…es (#59) * Bumped deps, fixes for image 0.25, better resizing filter. * Support for proper alpha blending. * Added support for premultiplied alpha blending. * Removed unused depedencies from image crate by disabling default-features, added missing doc (tests were broken because of deny(missing_docs) * Removed default features from crossterm dep. --------- Co-authored-by: atanunq <[email protected]>
- Loading branch information
1 parent
7c74a5a
commit 834da5f
Showing
8 changed files
with
114 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,66 @@ | ||
# viuer | ||
Display images in the terminal with ease. | ||
# `viuer` | ||
|
||
![ci](https://github.com/atanunq/viuer/workflows/ci/badge.svg) | ||
|
||
`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: | ||
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) | ||
- [Sixel](https://github.com/saitoha/libsixel) (behind the `sixel` | ||
feature gate) | ||
|
||
## Usage | ||
|
||
Add this to `Cargo.toml`: | ||
|
||
```toml | ||
[dependencies] | ||
viuer = "0.6" | ||
viuer = "0.8" | ||
``` | ||
|
||
For a demo of the library's usage and example screenshots, see [`viu`](https://github.com/atanunq/viu). | ||
For a demo of the library's usage and example screenshots, see | ||
[`viu`](https://github.com/atanunq/viu). | ||
|
||
## Examples | ||
|
||
```rust | ||
// src/main.rs | ||
use viuer::{print_from_file, Config}; | ||
|
||
fn main() { | ||
let conf = Config { | ||
// set offset | ||
// Set offset. | ||
x: 20, | ||
y: 4, | ||
// set dimensions | ||
// Set dimensions. | ||
width: Some(80), | ||
height: Some(25), | ||
..Default::default() | ||
}; | ||
|
||
// starting from row 4 and column 20, | ||
// display `img.jpg` with dimensions 80x25 (in terminal cells) | ||
// note that the actual resolution in the terminal will be 80x50 | ||
// 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](https://docs.rs/image/*/image/enum.DynamicImage.html), you can use it directly: | ||
Or if you have a [DynamicImage](https://docs.rs/image/*/image/enum.DynamicImage.html), | ||
you can use it directly: | ||
|
||
```rust | ||
// ..Config setup | ||
// ... `Config` setup | ||
|
||
let img = image::DynamicImage::ImageRgba8(image::RgbaImage::new(20, 10)); | ||
viuer::print(&img, &conf).expect("Image printing failed."); | ||
``` | ||
|
||
## Docs | ||
Check the [full documentation](https://docs.rs/crate/viuer) for examples and all the configuration options. | ||
|
||
Check the [full documentation](https://docs.rs/crate/viuer) for examples and all | ||
the configuration options. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters