Search

Display images in Terminal with this application written in C++

Can be implemented in different ideas


Display images in Terminal with this application written in C++


If you have an idea in mind of some TUI mode app that needs to display images in the terminal, such as similar ones: Ranger, fetch,… the TerminalImageViewer can be a good alternative.

TerminalImageViewer is a small program made with C++ to display images in a (modern) terminal using ANSI RGB codes and unicode block graphics characters.


Installation

First you will need the following dependencies installed on your system: Git, gcc, GNU Make and Image Magick.

After that run the commands in order:

git clone https://github.com/stefanhaustein/TerminalImageViewer
cd TerminalImageViewer/src/main/cpp
make
sudo make install

You can also install via Brew and Snap:

brew install tiv
sudo snap install --edge tiv


Usage

If you just run the tiv command there will be a help for all available parameters:

had
Terminal Image Viewer v1.1.0

usage: tiv [options] <image> [<image>...]

  -0 : No block character adjustment, always use top half block char.
  -256 : Use 256 color mode.
  -c <num> : Number of thumbnail columns in 'dir' mode (3).
  -d : Force 'dir' mode. Automatically selected for more than one input.
  -f : Force 'full' mode. Automatically selected for one input.
  -help : Display this help text.
  -h <num> : Set the maximum height to <num> lines.
  -w <num> : Set the maximum width to <num> characters.
  -x : Use new Unicode Teletext/legacy charactery (experimental)

The most basic way is to run the tiv command and indicate the path of the image, for example:

I had image.jpg

Another example, limiting the width to 40px and the height will be scaled proportionately:

tiv -w 40 image.jpg

Example:

tiv -w 40

There is also a version in Java, but it is outdated and not compiling.

For more information go to repository .


cpp cppdaily terminal


Share



Comments