UPDATE: 22nd November, 2019
Added version that uses 'mpv'. Details at bottom of blog-post
Personal notes on seven programs that provide some ability to display images in a POSIX terminal interface [bash environment specifically]. This is in no way an exhaustive list, nor does it claim to highlight the best applications available. These are merely notes made recently while investigating a solution for such a task.
source image: '"Michael Gehlert" by Harald Peter' http://piqs.de/fotos/192320.html
Catimg: https://github.com/posva/catimg
- MIT License.
- Simple to compile or run as shell script (script requires ImageMagick).
- Adjust output height and width.
- Limited colours with shell script.
- Blocky with both, but better with compiled binary
- Interporates transparency.
- Doesn't rely on file extensions.
hiptext: https://github.com/jart/hiptext
- License not specified.
- Generate images from specified ASCII characters.
- Grey-scale mode.
- Generate moving images from video file.
- Blocky but with support for half-blocks.
- Support for SIXEL.
- Compilation Errors (Ubuntu 17.10: 'libpng12-dev' missing installation candidate. Ubuntu 16.04: Library linking errors with Ubuntu 16.04).
lsix: https://github.com/hackerb9/lsix
- GPL-3.0 License.
- Works like 'ls' but shows thumbnails of image files in directory.
- Requires SIXEL compatible terminal, which are not common (Xterm works).
- Produces pleasing results.
- Can be slow.
- No customisation parameters.
w3mimgdisplay: http://w3m.sourceforge.net/
- MIT Licence [w3m].
- Part of w3m/w3m-img terminal web browser.
- Accurate image reproduction when it works.
- A lot depends on terminal/system used (Xterm works).
- Acts as new layer so it messes up terminals with multiple panels. However, it can work well, as seen with 'Ranger' for its image previews.
- Tricky to get working independantly N.B http://blog.z3bra.org/2014/01/images-in-terminal.html
tiv (TerminalImageViewer): https://github.com/stefanhaustein/TerminalImageViewer
- Apache License 2.0 License.
- Simple to compile c++ or Java version, minimal requirements.
- Uses multiple Unicode characters to create more pleasing results.
- Best at generating 'character-based' images at low resolutions.
- Can be slow at higher resolutions.
- Colour compatibility issues with some terminal/systems.
img2txt (libcaca): http://caca.zoy.org/wiki/libcaca
- WTFPL License.
- Classic terminal application and library.
- Many adjustable parameters.
- Caca by name; caca by nature.
- Better than nothing.
bash-drawille: https://github.com/mydzor/bash-drawille
- Bash implementation of more well-known Python version which uses braille characters to render an image from.
- As per above: experimental but usable pure bash program.
- Image reproduction rudimentary but useful for other graphical purposes.
'mpv' (--vo=tct): https://mpv.io/ (https://github.com/mpv-player/mpv/…/vo_tct.c)
- GPL-2.0-or-later [plus others] License.
- Uses half-block unicode so it's not the sharpest result but it does look clean and uniform.
- Output requires parsing and cleaning to make it useful.
- The major advantage of generating images this way is the availability and ease-of-use of mpv.
# Example command that cleans/prunes some of the problematic ANSI characters. # (sed commands could be tightened up; may need altering in some cases) mpv --no-terminal --vo=tct --vo-tct-width=80 --vo-tct-height=80 image.jpg \ | sed 's,\x1B\[?25l\x1B\[2J\x1B\[[0-9]*;[0-9]*f,\n,g' \ | sed -n '/^\x1B/p; /^\x1B/q' \ | sed 's,\x1B[[0-9]*;[0-9]*f,\n,g'