Skip to content

evilnerd/console-image-viewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CIV - Console Image Viewer

This command line tool scales and draws images (PNG, GIF and JPG currently) as text blocks or characters on the console. So you can preview images without having to open a window, or e.g. over an SSH connection.

To use it, call the executable, add a command ('blocks', 'chars') and add one or more arguments that specify a file or wildcard.

Render modes

Currently 2 render modes are supported.

Blocks

This mode renders the picture in blocks by changing the background color of characters on the console. It looks good, but is harder to copy and use somewhere else.

Preview Blocks

To use this type (for color output) e.g.

civ blocks ./mypic.png

or, for mono output:

civ blocks --mono mypic.png

Chars

This mode renders the picture by printing characters that vary in 'density', simulating light and dark tones. This mode is easy to copy and looks cool. Might require some eye-squinting.

Preview Chars

To use this, type:

civ chars mypic.png

Sizing

The program will try to detect the available width in the console you're using and scale the rendered image appropriately. You can also override this mechanism by specifying the 'max-edge'. In order to do so, specify the -e or --maxedge argument, followed by an integer value. The value you specify will be the size of the longest edge (so the height in vertical, or 'portrait' pictures and the width in horizontal or 'landscape' pictures).

Example:

civ blocks -e 50 mypic.png

State

This is a very early version, that just kind of works, but could use a lot more love. And tests.

Dependencies

Of course, I'm standing on the shoulders of giants. These are the libraries I'm using:

  • Termenv - For rendering color to the console
  • PTerm - For logging and some cool standardized way of outputing state to the user.
  • Consolesize-go - For determining the console size
  • Cobra - For handling and routing command line input and arguments.

About

View images from the console - in Go.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages