Go to file
atanunq 8c3f26f296
Update README.md
2019-10-01 01:24:19 +01:00
.github/workflows Add cargo fmt and clippy in actions 2019-09-30 00:30:17 +01:00
img [ImgBot] Optimize images 2019-08-08 20:46:18 +00:00
src Change argument positions 2019-10-01 01:10:07 +01:00
.gitignore Removed WASI Readme 2019-05-28 15:21:09 -07:00
Cargo.lock Prepare 0.2.2 release 2019-10-01 01:11:28 +01:00
Cargo.toml Prepare 0.2.2 release 2019-10-01 01:11:28 +01:00
LICENSE-MIT Add LICENSE-MIT 2019-04-12 18:11:33 +03:00
README.md Update README.md 2019-10-01 01:24:19 +01:00
wapm.toml Prepare 0.2.2 release 2019-10-01 01:11:28 +01:00

README.md

viu

Description

A small command-line application to view images from the terminal written in Rust. It uses lower half blocks (▄ or \u2584) to fit 2 pixels into a single cell by adjusting foreground and background colours accordingly.

Features (see Usage):

  • Animated GIF support
  • Accept media through stdin
  • Custom dimensions

Installation

From source

Standard

Installation from source requires a local Rust environment.

git clone https://github.com/atanunq/viu.git

# Build & Install
cd viu/
cargo install --path .

# Use
viu img/giphy.gif

Or without cloning:

cargo install viu
WASI

First, you will need the WASI target installed in your Rust system:

rustup target add wasm32-wasi --toolchain nightly

Once WASI is available, you can build the WebAssembly binary by yourself with:

cargo +nightly build --release --target wasm32-wasi

This will create a new file located at target/wasm32-wasi/release/viu.wasm.

When the wasm file is created you can upload it to wapm or execute it with wasmer:

wapm publish
# OR
wasmer run  target/wasm32-wasi/release/viu.wasm --dir=. -- img/giphy.gif

Binary

A precompiled binary can be downloaded from the release page.

From wapm

Viu can be installed in Linux, macOS and Windows using wapm:

wapm install -g viu

Packages

Arch Linux

There is an AUR package available for Arch Linux.

Usage

Demo

Demo

Demo

Ctrl-C was pressed to stop the GIFs.

Examples:

  • viu img/giphy.gif
  • viu img/*
  • viu ~/Pictures -rn

The shell will expand the wildcard above and viu will display all the images in the folder one after the other. For a more informative output when dealing with folders the flag -n could be used.

When viu receives only one file and it is GIF, it will be displayed over and over until Ctrl-C is pressed. However, when couple of files are up for display (second example) the GIF will be displayed only once.

Aspect Ratio

If no flags are supplied to viu it will try to get the size of the terminal where it was invoked. If it succeeds it will fit the image and preserve the aspect ratio. The aspect ratio will be changed only if both options -w and -h are used together.

Command line options
USAGE:
    viu [FLAGS] [OPTIONS] [FILE]...

FLAGS:
    -m, --mirror         Display a mirror of the original image
    -n, --name           Output the name of the file before displaying
    -1, --once           Only loop once through the animation
    -r, --recursive      Recurse down directories if passed one
    -t, --transparent    Display transparent image with transparent background
    -v, --verbose        Output what is going on

OPTIONS:
    -h, --height <height>    Resize the image to a provided height
    -w, --width <width>      Resize the image to a provided width

ARGS:
    <FILE>...    The image to be displayed

TODOs:

  • Reimplement STDIN image support based on #7
  • Use crossterm to add Windows support and remove magic terminal escape sequences
  • Tests