Linux Terminal 显示图像

其实很久之前我就在想linux终端里能否显示图像呢?然而这个问题一直拖延至今,直到google过程中发现了Tiv(TerminalImageViewer)

Tiv

本文我要介绍的是tiv这个小巧的工具,它是由C++写成的
Github: https://github.com/stefanhaustein/TerminalImageViewer

tiv使用RGB ANSI代码unicode块图形字符在(现代)终端中显示图像,这也就是说tiv只能 像素化 的显示图像。

1
2
3
git clone https://github.com/stefanhaustein/TerminalImageViewer.git
cd TerminalImageViewer/src/main/cpp
make

之后即可运行tiv

./tiv -help 查看帮助

1
2
3
4
5
6
7
8
9
10
11
12
Terminal Image Viewer

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. Automatially 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.

./tiv ~/1.png
img

当然还可以 ./tiv ~/1.png -0
img

当然我也试过 fim 但觉得总有点差强人意,最后还是选择tiv,尽管它只能像素化的显示图像。。。