Can I see images and watch movies inside the terminal emulator? In case of virtual console I can do it via framebuffer, but what about terminal emulators?
- WRQ Reflection
You can display the images with the afore mentioned PySixel, which seems to be able to do the necessary conversions. Another option is to use tools from
netpbm. I had good results using the following to convert and display a JPEG image on mlterm:
jpegtopnm image.jpg | pnmquant 256 | ppmtosixel >/dev/tty
XTerm can also display Sixel images, though support is currently limited to 16 colours (and is also buggy). An archive containing sample images can be downloaded here, though the scripts seem to be broken. XTerm doesn't display the exact format output by
ppmtosixel (it doesn't support the control sequences used at the start/end). Before finding
PySixel, I used the following scrip to hack the
ppmtosixel output into something XTerm will display:
#!/bin/bash echo -e '\eP0;0;0;q"1;2;400;400' jpegtopnm "$1" | pnmquant 16 | ppmtosixel | tail -n +2 | head -c -3 echo -e '\x1b\x5c\x0d' tput cup "$(tput lines)" 0
The images won't be displayed in the default VT420 mode. Only in VT240, VT241, VT330 or VT340 modes will they be displayed. Also the
--enable-sixel-graphics build option is required. I found best results with VT340 (
xterm -ti vt340). Here are the results (the first is a very cool tron image from the sample archive):
For instance - I want to change the background of my terminal?
printf '\033}bp%s\000' \ 'http://hdwalldesktops.com/wp-content/uploads/2014/02/background-backgrounds-high-resolution-abstract-picture-background-wallpaper.jpg'
It emulates a slightly extended vt100 with some extensions and bling thrown in.
> Most escapes supported by xterm, rxvt etc. work > Xterm 256 color escapes work > Backgrounds (bitmap, scalable/vector, animated gif, videos) > Transparency > Bitmap and scalable fonts supported > Themes for the layout and design > URL, file path and email address detection and link-handling > Inline display of link content > Multiple copy and paste selections and buffer support > Works in X11 > Works in Wayland > Works directly in the linux framebuffer (fbcon) > Can be finger/touch controlled > Scan scale by UI scaling factors > Can render using OpenGL or OpenGL-ES2 (not a requirement - just an option) > Can display inlined media content (images, video, documents) > Can do multiple "tabs" > Can do splitting into multiple panes > Block text selection > Drag and drop of text selections and links > Can stream media from URLs > Tab switcher has live thumbnail content > Single process, multiple windows/terminals support > Fast (gives urxvt a run for its money) > Themable visual bell > Compress backscroll > Text reflow on resize > Color palette selection > More...
You see that above? It does this in the framebuffer.
I recently discovered Frame Buffer Image viewer, fbi.
In the Unix world terminal emulators emulate serial terminals, where the data stream to be shown to the user is sent one at a time over a serial line.
In the modem time this was typically around 1000-2000 characters a second, but may be much faster today if only emulated hardware is involved. It was then up to the terminal to understand the bytes sent. Usually this was for showing characters, moving the cursor and manipulating the screen display. A few terminals could switch to graphics modes - gnuplot support quite a bit - but the bandwidth is much too small to do anything interesting in terms of video.
Still, for a modern computer with emulated hardware a terminal emulator can do quite a lot. Try searching for images with the search term "ttyquake" to see some of then. I would say though that if you crave HD you will most likely be disappointed.