Skip to main content

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

Metadata

Release files for vimg 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vimg 0.4.3
File Size Uploaded Provenance Actions
vimg-0.4.3.tar.gz 15.3 kB Without provenance Details for vimg-0.4.3.tar.gz

Release files / vimg-0.4.3.tar.gz

Download URL vimg-0.4.3.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6e050a2a31f6534a4828a8a82f16db481574c6bb9cb16f0182ddcd2258a84b0a
BLAKE2b-256 checksum
How to use checksums
bd7247a805904c0338b8529e84682223452a3c2321a16067f229157ef86de5a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for vimg 0.4.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page