This is a quick mockup I copy and pasted together. I imagine this being super cool and useful.
Does something like this exist already?
Update 2021-03-02
Viu is an image viewer that can display images using either the kitty, iterm, or libsixel approach. It also has a fallback mode to display blocky ascii images.
Update 2018-12-31
The all around terrific terminal emulator kitty has an icat
command to display images (does not work within tmux). Kitty also enables image previews within ranger (a terminal file manager), which is the method I currently use the most often (works within tmux).
While the main purpose of w3m
is to provide in-console web browsing, it can also be used to view images in terminal. The relevant packages to install are w3m
and w3m-img
(on Ubuntu at least). You then need to disable the external image viewer wither by passing -o ext_image_viewer=0
or by going into the options menu ('o') inside w3m
and disable external image viewing.
Now, typing w3m <image_name>
will display the image in terminal. w3m
will use the entire terminal window, so you cannot see your previous commands until quitting w3m
(think less
, not cat
). Note that if the image is to big to fit the terminal window, it will still be opened externally (in imagemagick for me). Also note that even though I read multiple places that w3m
inline images would not work for gnome-terminal
, it is working fine for me. It is a little annoying that you have to type q
twice to close first the image and then w3m
.
tycat
is part of terminology
and displays images like cat
displays text files and like imgcat
works for iTerm2 on OS X.
Install libsixel-bin
and any compatible terminal (examples mentioned under 'Requirements' of this readme, for example mlterm
or xterm
compiled with the right flags and you can view images with the img2sixel
command. Both these packages are available in the Ubuntu repos.
Then there is FIM which is an improved version of fbi
. The homepage states that it can display images not only with the framebuffer, but also with X. However, it won't install for me. Edit I got it running by downloading the 0.5 trunk version, running ./configure --disable-exif
and then temporarily removing anaconda
(python distribution) from my path since it caused a conflict with libpng
before running make
and sudo checkinstall
(you need to write in a version number manually with checkinstall
, but it makes it easier to remove than make install
). However, images are still displayed in a separate window, although like with fbi
you do not need to be running X which is kind of cool.
You could also get creative and use the jupyter-qtconsole as your system console, configure it to show plots inline (%matplotlib inline
) and then display the image using matplotlib =)
feh
is using X to display images, but feh -x
pops them up in a borderless window that can be quickly closed with q
or x
. Although images are not displayed in the terminal per say, I thought it was worth mentioning since it is the least intrusive way I have found so far and what I am using until gnome-terminal
gets an imgcat
/tycat
equivalent.
apt install libsixel-bin mlterm; mlterm; img2sixel test.jpg
works on Ubuntu 19.10! I tried xterm too, but no output there
imlib2
so it doesn't seem to matter much ;)
Maybe caca is what you want. For images:
sudo apt-get install caca-utils
cacaview /PATH/TO/image.jpg
Make sure your terminal window is big enough.
For example, here is how this image is displayed in cacaview
:
I sometimes used it for fun to watch videos as ASCII in mplayer :) Like this:
mplayer -vo caca /PATH/TO/video.mpg
img2txt
"watch videos as ASCII" But... why?
because you want to? because you need to peek the video and the only thing you got is terminal? Because if you do not need something it does NOT mean others follow.
Commented
Feb 22, 2018 at 17:47
I have written a small C++ tool to convert images to ANSI RGB control codes and Unicode block graphics characters for modern terminals supporting these features: https://github.com/stefanhaustein/TerminalImageViewer
Installation:
git clone https://github.com/stefanhaustein/TerminalImageViewer.git
cd TerminalImageViewer/src/main/cpp
make
sudo make install
Usage:
tiv <image(s)>
Edit: Changed links / instructions to the main repository; added usage.
Examples:
I made a very quick, simple one line shell function which solves the original question exactly as requested in the mockups. Note the screenshots below are actual images, not mockups.
function lsix() { montage -tile 7x1 -label %f -background black -fill white "$@" gif:- | convert - -colors 16 sixel:-; }
Prerequisites are minimal: xterm and ImageMagick (apt-get install xterm imagemagick
). Your xterm must be in vt340 mode, which you can either set in ~/.Xresources
or from the command line (xterm -ti vt340
).
Limitations: Only 16 colors are used over all images shown. That means, an image might look better when viewed on its own. (See below).
UPDATE
While my above answer is still correct, I've created an even better shell script which is able to do an 'ls' of images directly into a terminal. There are all sorts of improvements I added to make the images look better (more colors, proper alpha, JPEG orientation, handling lots of images, compact tile layout,...). It's still a fairly small program, but I figured people might want to customize it, so I've put it up on github: https://github.com/hackerb9/lsix.
You can't do so in a terminal window, but you can do so in a Linux console using fbi
. You need a framebuffer to allow this to work:
sudo apt-get install fbi
Go to a Linux console (using Ctrl+Alt+F1) and enter fbi <filename>
It should show your image.
fbi
. The homepage states that it can display images not only with the framebuffer, but also with X. However, it won't install for me.
Commented
Nov 14, 2015 at 22:32
Another tool is catimg which can be installed using
sudo apt-get install catimg
It does not actually view the image but turn it into colored characters.
Another alternative is terminology:
https://www.youtube.com/watch?feature=player_embedded&v=ibPziLRGvkg
You can install it on Ubuntu by adding the enlightenment-git repository:
sudo add-apt-repository ppa:enlightenment-git/ppa
sudo apt-get update && sudo apt-get install terminology
Or in recent Ubuntu releases >= Vivid (15.04) it can be fetched from the official repositories.
sudo apt-get install terminology
To view an image, type tycat IMAGENAME
, and to view a list of images, type tyls -m
.
tycat
to display an image inline and tyls -m
to display medium sized thumbnails in a directory.
Commented
Nov 14, 2015 at 21:01
terminology
is in the official Ubuntu repositories, no PPA needed.
Just to add to the collection (perhaps also for future me), there is also an actively developing/maintained software named chafa that works similar to catimg. Both can show images in addition to GIFs.
# install chafa
sudo apt install chafa
# open a file
chafa file.gif
# install catimg
sudo apt install catimg
# open a file
catimg filename.gif
There's actually such a project named TermKit, if you'd like to test it - check out http://blog.easytech.com.ar/2011/05/21/playing-with-termkit-with-chrome/ but it's quite unfinished (since you seem to have a Mac, you should try the Mac-version since it's "the original")
So yes, it's an idea worth exploring, however - the switch between graphical and text-only mode must be quick since I don't always need the images viewed. Also - it needs to be fully compatible with e.g. Vim..
chromium-browser
in the repos, so that it's quite easy to install something Chromelike - I haven't really tried TermKit on my computer (w/ Chromium installed, but using Fx as main) since I'm quite dependent on Vim, and can't really use a terminal that won't give me my beloved text editor ;)
In addition to Joel's answer, Ranger terminal file manager with w3mimgdisplay
extension can show images in full color and also supports "oldschool ASCII art previews". Here is how you can enable it. This may not be the exact thing you were looking for but a way to preview images in terminal.
I wrote a tool to do this. I named mine Show Image In Terminal (siit
). It assumes you have a 256 color terminal and UTF8 support, and it's written in Perl.
I dropped it in my ~/bin
. It assumes you have Image::Magick, Term::Size, Getopt::Long and Time:HiRes, which should all be available in your distro's repositories, or CPAN.
My intent was to ssh into my house, and quickly view images without launching a display over X. Script scales to appropriate width/height for the terminal you are in. I used UTF8 characters to effectively double the vertical resolution of your terminal, which really helps clarity. YMMV.
This does not exist; gnome-terminal
is only capable of diplaying text, at least as far as I know.
However, you can call an image viewer from the commandline to see your pictures in a particular folder. So, going off of your mockup above showing you listing all .jpg pictures in the current folder, you can use Eye of GNOME (Ubuntu's default image viewer) from the commandline for something similar:
eog *.jpg &
Note that the window which comes up will only show one image at a time, though you can use the provided arrow buttons to cycle between them.
eog *.jpg & disown
is better as otherwise the EOG will likely exit when the terminal closes. N.B. I wish EOG was still Ubuntu's defualt image viewer - shotwell is good, but tries to index my 30GB+ of pictures.... and is slow and annoying anyway
Here are some solutions in node.js
(Installation instructions here).
To install either, type npm install -g <package_name>
where package_name
is either of picture-tube
or imaging
.
Another option is ueberzug, which you can install using pip. Here I'm using it with fzf-ueberzogen, so to display image previews, you simply run the fzf-ueberzogen.sh
command in the current directory as shown below.
We can indeed display images in the terminal. What we need is a terminal program that supports the Sixel protocol or a similar protocol.
lsix, written by hackerb9, is one such program that uses Sixel to display images.
There are also other programs like timg that utilize Sixel. And timg can be easily installed via package management software on most Linux distributions and macOS(via Homebrew).
You can find more programs that use Sixel at this URL: https://www.arewesixelyet.com/.
I don't know if this will suit your request, but here is my personal work -- lss.
This is an application designed to be an everyday replacement for GNU coreutils ls, with thumbnail display capability via sixel (of course, a sixel-capable terminal is required).
feh
! I know it's not in the terminal, but it does it's job.