Coder Social home page Coder Social logo

vimg's Introduction

vimg: A CLI image viewer.

Author: Johannes Hansen

Why?

If you are like me, you spend a lot of time in command line environments. One of the few things that are hard to deal with in such an environment is images.

This little tool is meant to allow for quick viewing of image files in the command line.

The image is rendered using a combination of background color, foreground color and unicode character for each character cell to optimally represent the original pixels. The challenge is the limited color palette of 256 colors.

In the simplest case, each character cell represents one pixel. However, the resolution can be increased by printing unicode characters that better capture the structure of the image. Alternatively, the color accuracy can be improved by mixing two available colors in foreground and background, thus losing the gained resolution.

The default mode attempts to optimize the rendering by optimizing resolution in areas of high detail, and optimizing color accuracy in areas of low detail.

Installation

$ pip install vimg

Requirements

A terminal that supports 256 colors.

The script is based on curses and opencv for Python.

Usage

$ vimg path/to/image

GUI modes

Once in the GUI, you can change between different viewing modes:

Key shortcut Mode Description
c color (default) display optimal representation of image
f fast display image in fast mode (reduced resolution)
a ascii display a black-and-white representation of the image
e edge (experimental) edge detection based rendering
+/- -- zoom in/out (by 30%)
h j k l
or arrow keys
-- move view (by 10%)
0 -- reset zoom
r -- refresh the screen
q -- quit

Notes

The results will be better if you use a font that correctly displays unicode block element characters with the full line height, such as DejaVu Sans.

Limitations

The script currently only supports image files that are natively supported by OpenCV (.jpg, .png, .bmp).

To Do

Future plans include:

  • Support for more image file types, e.g. .gif
  • Improvement of the edge detection mode
  • Make opencv dependency optional
  • Improve color gradients at contrast-rich edges

vimg's People

Contributors

jnhansen avatar

Stargazers

Harshad Sharma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.