A small command-line application to view images from the terminal written in Rust.

Overview

Description

A small command-line application to view images from the terminal written in Rust. It is basically the front-end of viuer. It uses either iTerm or Kitty graphics protocol, if supported. If not, lower half blocks (▄ or \u2584) are displayed instead.

Based on the value of $TERM, viuer decides which protocol to use. For half blocks, $COLORTERM is inspected. If it contains either truecolor or 24bit, truecolor (16 million colors) will be used. If not, it will fallback to using only ansi256. A nice explanation can be found in this gist.

Features

  • Native iTerm and Kitty support
  • Animated GIF support
  • Accept media through stdin
  • Custom dimensions
  • Transparency

Installation

From source (recommended)

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

Binary

A precompiled binary can be downloaded from the release page. GPG fingerprint is B195BADA40BEF20E4907A5AC628280A0217A7B0F.

Packages

Arch Linux

Available in community/viu.

NetBSD

Available in graphics/viu.

Usage

Examples

On a Kitty terminal:

Kitty

On a Mac with iTerm:

iTerm

Using half blocks (Kitty protocol and tmux do not get along):

Demo

Demo

Demo

Ctrl-C was pressed to stop the GIFs.

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 the GIF will be displayed only once.

iTerm note

iTerm can handle GIFs by itself with better performance, but configuration through --once and --frame-rate will have no effect there.

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]...
    When FILE is -, read standard input.

FLAGS:
    -b, --blocks         Force block output
    -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
    -s, --static         Show only first frame of gif
    -t, --transparent    Display transparent image with transparent background

OPTIONS:
    -f, --frame-rate     Play gif at the given frame rate
    -h, --height     Resize the image to a provided height
    -w, --width       Resize the image to a provided width

ARGS:
    ...    The image to be displayed
Comments
  • /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found

    /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found

    Got this error on Ubuntu 18.04, using https://github.com/atanunq/viu/releases/download/v1.3.0/viu

    viu: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by viu)
    

    Attempt to fix with, but didn't work:

    apt install -y libc6 libc-bin
    
    
    opened by vamoko 18
  • Provide PGP signatures for release versions

    Provide PGP signatures for release versions

    It would be nice if you could sign release versions source code .tar.gz (e.g. https://github.com/atanunq/viu/releases/tag/v1.0) with a PGP/GPG key and attach the signature to the tag. If you need help, the Arch wiki has a good section on it: https://wiki.archlinux.org/index.php/GPG#Signatures

    You'd want a detached signature so that you can attach it as a separate file. You could also add signatures for the attached binary.

    opened by krathalan 9
  • Works fine with 24bit outside tmux, falls back to lower color support inside tmux

    Works fine with 24bit outside tmux, falls back to lower color support inside tmux

    First of all, thanks a lot. viu is an amazing tool, I love it.

    I set export COLORTERM='24bit' in my ~/.bashrc, and now viu works pretty well outside tmux. However, inside tmux next-3.2, and despite echo $COLORTERM still returning 24bit, viu fails to use 24bit colours and falls back to a base support.

    Is this a known issue and would you know how I can fixe it? Thanks a lot.

    opened by Kabouik 8
  • Quality on mac is literally unusable

    Quality on mac is literally unusable

    Not sure if I am missing something,

    Installed like this: cargo install viu

    then opened an image like this: viu ~/Desktop/tenor.gif

    The quality is like this:

    Screen Shot 2019-12-14 at 1 47 34 PM

    While original gif is this

    tenor

    help wanted 
    opened by ishandutta2007 8
  • Directory support

    Directory support

    Please extend the positional argument FILE to accept a directory as well. It would be great if viu could detect the images in the directory and render them.

    opened by jarun 6
  • Added support for WASI and integrated into WAPM

    Added support for WASI and integrated into WAPM

    This PR adds support for exporting into WebAssembly/WASI, so the package can be distributed as a .wasm binary and executed universally (in Mac, Linux and Windows) using wasmer.

    I already published the first version of the package on WAPM so people can install and use it. WAPM package page: https://wapm.io/package/viu

    Instructions

    1. Install Wasmer+wapm
    curl https://get.wasmer.io -sSfL | sh
    
    1. Install viu with wapm
    wapm install -g viu
    
    1. Run viu
    viu --dir=. img/explode.gif
    

    Note: Why the --dir=. is needed? Because WASI establish a set of permissions on top of directories, and as we want the wasm file to access the file, we need to explicitly add permissions to it.

    Publish

    To publish next versions of the package in wapm, just do:

    wapm publish
    
    opened by syrusakbary 6
  • No precompiled binary available

    No precompiled binary available

    Apologies if I am being really dense here. There are no precompiled binaries in the release page, despite what the README says. There is a signature, and two source archives.

    image

    opened by dashavoo 5
  • Viu incompatible with python 3.8

    Viu incompatible with python 3.8

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

    opened by CaspianA1 5
  • transparent images bug

    transparent images bug

    this image: thumb

    when saved and used with viu -t thumb.png

    displays a ugly red line in the border of the cover and the transparent part of the image. The image is done programmatically with python pillow code that glues 3 images, first in a side and the two others on top on the right side, and where the images are missing, a transparent area is glued instead.

    My 'original transparent' images for the missing images sets a background rgba color of (255, 0,0,0) which is obviously the source of the 'red'.

    Should i use (0,0,0,0) always, as a assumption that the alpha is always black for '-t' to work? Btw this has no problems in kitty, it's a xterm problem.

    opened by i30817 4
  • Aspect ratio off on iTerm2

    Aspect ratio off on iTerm2

    I've curl https://via.placeholder.com/20 -o 20.png to product a 20x20 png. Then I run viu 20.png in iTerm2.

    Here are the results:

    Screen Shot 2021-03-13 at 4 23 01 PM

    As you can see the aspect ratio is clearly off. I suppose this has something to do line height setting? Does iTerm2 have API for polling this?

    opened by thorlucas 4
  • Implement truly transparent pixels

    Implement truly transparent pixels

    This implements "truly" transparent pixels as described in #10, while throwing away the old way (the grid). I don't know if you want to keep it or not.

    I'm using the color Color::Magenta as a placeholder for transparency, because the colorspec doesn't support it otherwise, and the rest of the code uses RGB colors exclusively. This shouldn't break displaying actually magenta pictures.

    Code may or may not be terrible; I'm a Rust noob.

    opened by L3viathan 4
  • Integration with fzf

    Integration with fzf

    Does anybody know how to integrate the viu with fzf? My goal it to make fzf print the pdf cover image in the preview section. At the moment, my humble code is

    function fpp()
    {
      # open PDF using fuzzy finder with preview
      rg --type 'pdf' --files | fzf  --preview-window down:80% --preview '
          pdftoppm -f 1 -l 1 -singlefile -jpeg -tiffcompression jpeg -- {1} | viu -
          '
    }
    

    It prompts to image

    Any help is welcome :)

    opened by tapyu 1
  • absolute offset, -x and -y seem to not be working

    absolute offset, -x and -y seem to not be working

    Hi there, thanks for making this amazing set of tools! I've been playing around with if for a few days and it works amazing!

    I installed viu from homebrew

    ▶ viu --version
    viu 1.4.0
    

    and I am trying to use the -a option to absolutely offset my picture, but neither -a, -x or -y seem to be working sadly. It looks like this plugin hasn't been released in a while. would it be possible to publish a new release?

    I'm currently working on migrating a picture preview plugin in telescope to use VIU, and it seems that the terminal inside the editor would work much better if I were able to position things absolutely :) (parameters we already have access to too), would it be possible to release a new build of this plugin to allow package managers and users on various different kinds of machines to natively upgrade to it? I could compile the rust code, but that would generate an OSX executable that only a small sub-set of users could use.

    opened by HendrikPetertje 0
  • Consider adding a --fit flag

    Consider adding a --fit flag

    I used tiv in the past. I now wanted to optionally support viu. In tiv -h -w are max height/max width. I think this is what most expect.

    My use case: I use tiv and viu in my fish_greeting function on all my linux machines (shell script).

    Image using tiv: tiv

    Same image using viu: viu

    I don't think changing the behaviour would be an issue for many users. To avoid doing a breaking change I would suggest adding a --fit option that changes the behaviour to make -h and -w max measurements instead. Alternatively you can also reconsider #55.

    I also noticed that the colors are off in viu.

    opened by raldone01 0
  • Mirror option is not working

    Mirror option is not working

    At least for random pngs.

    testcase:

    #! /usr/bin/env python3
    
    from PIL import Image
    import subprocess, io
    
    solid_black = Image.new('RGBA', (50,50), (0, 0, 0, 255))
    solid_red = Image.new('RGBA', (50,50), (255, 0, 0, 255))
    
    combined = Image.new('RGBA', (100, 50))
    combined.paste(solid_black, box=(0,0))
    combined.paste(solid_red, box=(solid_black.size[0],0))
    
    #for comparasion, original
    combined.show()
    #for bug view
    with io.BytesIO() as f:
        combined.save(f, format='png')
        #supposed to be reversed
        subprocess.run(['viu', '-m', '-'], input=f.getbuffer())
    
    opened by i30817 3
Releases(v1.4.0)
Owner
Atanas Yankov
Atanas Yankov
❗️ Small script to view GitHub notifications in the terminal

github-notifications Small script to view GitHub notifications in the terminal Shows and color-codes the notification source, eg if you're the owner o

Brian Shaginaw 1 Jan 10, 2022
Small command-line tool to switch monitor inputs from command line

swmon Small command-line tool to switch monitor inputs from command line Installation git clone https://github.com/cr1901/swmon cargo install --path .

William D. Jones 5 Aug 20, 2022
Command-Line program that takes images and produces the copy of the image with a thin frame and palette made of the 10 most frequent colors.

paleatra v.0.0.1 Command-Line program that takes an image and produces the copy of the image with a thin frame and palette made of the 10 most frequen

Beka Modebadze 24 Dec 29, 2022
View Source, but for terminal escape sequences

Escape Artist Escape Artist is a tool for seeing ANSI escape codes in terminal applications. You interact with your shell just like you normally would

Reilly Wood 8 Apr 16, 2023
Terminal UI for leetcode. Lets you browse questions through different topics. View, solve, run and submit questions from TUI.

Leetcode TUI Use Leetcode in your terminal. Why this TUI: My motivation for creating leetcode-tui stemmed from my preference for tools that are lightw

Akarsh 8 Aug 10, 2023
A git sub-command to view your git repository in the web browser

git-view A git sub-command to view your git repository in the web browser! About Are you also frustrated from moving your hands away from the keyboard

Hamothy 5 Sep 26, 2022
A little program written in Rust that prints random PNG images to the terminal in text grabbed from an image repo.

Cermic A little program written in Rust that prints random PNG images to the terminal in text grabbed from an image repo. NOTE: As of right now, Cermi

Jackson Novak 7 Oct 1, 2022
This is a simple command line application to convert bibtex to json written in Rust and Python

bibtex-to-json This is a simple command line application to convert bibtex to json written in Rust and Python. Why? To enable you to convert very big

null 3 Mar 23, 2022
A command-line utility which aligns a block of text within the terminal (or a specified number of columns), written in Rust.

align: a command line utility for aligning text. ⭐ Overview Aligns text within the terminal (or a specified number of columns). The text is treated as

Khalil Ouali 6 Aug 11, 2023
A discord bot to view & monitor OpenSea collections, written in Rust

Titan What is this This is a discord bot to monitor OpenSea collections and get info about them, including: Floor Price Activity Sales per Hour And mo

theldb 3 Oct 11, 2022
A small command-line utility for encoding and decoding bech32 strings

A small command-line utility for encoding and decoding bech32 strings.

Charlie Moog 5 Dec 26, 2022
A lightweight command line utility with some small functions for CTFs.

Ice Ice is a lightweight command line utility to help with simple problems encountered while playing CTFs. Extracted from graveyard NOTE: Most of the

Aquib 12 Dec 19, 2022
rsv is a command line tool to deal with small and big CSV, TXT, EXCEL files (especially >10G)

csv, excel toolkit written in Rust rsv is a command line tool to deal with small and big CSV, TXT, EXCEL files (especially >10G). rsv has following fe

Zhuang Dai 39 Jan 30, 2023
A tool crate to quickly build rust command line application.

Falsework A tool crate to quickly build rust command line application.

Leon Ding 103 Dec 12, 2022
Command line application for searching

maven_search_rs Command line application for searching in https://search.maven.org Usage Non-interactive $ maven-search -f maven wicket-core The abov

Martin Grigorov 1 Nov 5, 2021
Application microframework with command-line option parsing, configuration, error handling, logging, and shell interactions

Abscissa is a microframework for building Rust applications (either CLI tools or network/web services), aiming to provide a large number of features w

iqlusion 524 Dec 26, 2022
A command line application which sets your wall paper with new image generating pollens once they arrive.

pollenwall Table of Contents pollenwall About Installation Binary releases Build from source Usage Command Line Arguments Running as a service MacOS L

Pollinations.AI 2 Jan 7, 2022
omekasy is a command line application that converts alphanumeric characters in your input to various styles defined in Unicode.

omekasy is a command line application that converts alphanumeric characters in your input to various styles defined in Unicode. omekasy means "dress up" in Japanese.

null 105 Nov 16, 2022