Skip to content

Commit

Permalink
Release 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
atanunq committed Dec 13, 2020
1 parent bf35179 commit f460153
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Unreleased

## 0.3.0
- Add iTerm support and `use_iterm` Config option
- Add support for remote Kitty printing, through escape sequences
- Rename `has_kitty_suport` to `get_kitty_support`
- Remove `kitty_delete` Config option

## 0.2.0
- Add support for local Kitty printing
- Add `restore_cursor`, `use_kitty` and `kitty_delete` Config options
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "viuer"
version = "0.2.0"
version = "0.3.0"
authors = ["Atanas Yankov <[email protected]>"]
edition = "2018"
description = "Display images in the terminal"
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ Display images in the terminal with ease.

![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, [Kitty graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol.html)
is used if support for it is detected, resulting in full resolution images in the terminal.
`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)

For a demo of the library's usage and example screenshots, see [`viu`](https://github.com/atanunq/viu).

## Examples

```toml
# in Cargo.toml, under [dependencies]
viuer = "0.2"
viuer = "0.3"
```
```rust
// in src/main.rs
Expand Down
8 changes: 4 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ pub type ViuResult<T = ()> = std::result::Result<T, ViuError>;
/// Custom error type for `viu`ing operations.
#[derive(Debug)]
pub enum ViuError {
/// Error while doing transformations with the [`image`] crate.
/// Error while doing transformations with the [`image`] crate
Image(image::ImageError),
/// Error while doing IO operations.
/// Error while doing IO operations
IO(std::io::Error),
/// Error while doing [`crossterm`] operations.
/// Error while doing [`crossterm`] operations
Crossterm(crossterm::ErrorKind),
/// Invalid configuration provided.
/// Invalid configuration provided
InvalidConfiguration(String),
/// Error while creating temp files
Tempfile(tempfile::PersistError),
Expand Down
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
//!
//! This library contains functionality extracted from the [`viu`](https://github.com/atanunq/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. The [Kitty graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol.html)
//! is partially supported. It is used by default. If the terminal doesn't support it, `viuer` will fallback
//! to using regular half blocks instead (▄ and ▀).
//! provided by the [`image`] crate. Both the [Kitty](https://sw.kovidgoyal.net/kitty/graphics-protocol.html)
//! and [iTerm](https://iterm2.com/documentation-images.html) 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
Expand Down Expand Up @@ -41,7 +42,8 @@ pub use error::ViuError;
pub use printer::{get_kitty_support, is_iterm_supported, resize, KittySupport};
pub use utils::terminal_size;

/// Default printing method. Uses Kitty protocol, if supported, and half blocks otherwise.
/// Default printing method. Uses either iTerm or Kitty graphics protocol, if supported,
/// and half blocks otherwise.
///
/// Check the [Config] struct for all customization options.
/// ## Example
Expand Down
2 changes: 1 addition & 1 deletion src/printer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub trait Printer {
pub fn resize(img: &DynamicImage, width: Option<u32>, height: Option<u32>) -> DynamicImage {
let (w, h) = find_best_fit(img, width, height);

// find_best_fit returns values in terminal cells. Hence we multiply by two
// find_best_fit returns values in terminal cells. Hence, we multiply by two
// because a 5x10 image can fit in 5x5 cells.
img.resize_exact(w, 2 * h, image::imageops::FilterType::Triangle)
}
Expand Down

0 comments on commit f460153

Please sign in to comment.