The terminal is very fast and convenient way to quickly access directories and files (faster than find and click on the directory). One thing that it cannot show in text-mode is "pictures". What is a best way to view pictures (like you see images thumbnail in Nautilus) when you are working in the terminal (e.g. command nautilus or any program - but should be fast and convenient)?
843k 199 199 gold badges 1.8k 1.8k silver badges 2.2k 2.2k bronze badges asked Mar 29, 2012 at 18:50 5,137 6 6 gold badges 26 26 silver badges 31 31 bronze badges Commented Mar 29, 2012 at 20:32I just run a terminal emulator under my desktop enviroment. So you have the advantages of both at hand.
Commented Mar 23, 2014 at 16:05Gotta object to the close votes here as there is a substantial difference between the need to view images files from a (presumably GUI) terminal (this question) and the need to view them on the console (the other question).
Commented Mar 23, 2014 at 19:50I provide a list of pretty much all your options here in this Q&A: How to get JPEG thumbnails quickly
Commented Mar 24, 2014 at 2:17 how to do it from inside the terminal askubuntu.com/questions/97542/… Commented Mar 21, 2016 at 15:37The way to "double-click" on a file from the command line is xdg-open .
If you're on Gnome (probably, if you're using Nautilus), you can use eog directly, or any other image program ( feh is quite good).
If you want to consult image-name file easilly.
9,794 13 13 gold badges 50 50 silver badges 81 81 bronze badges answered Mar 29, 2012 at 19:05 41.1k 16 16 gold badges 89 89 silver badges 113 113 bronze badges feh even works with multiple URLs! Commented May 21, 2016 at 15:16@Searene Yeah! Long life to feh . But I observe that feh has no zoom or any other function whatsoever. eog , however, is also lightweight and, in addition, it can zoom, rotate and browse the images in a folder :). Just for the people to know before they make a choice.
Commented Jun 1, 2016 at 13:19although eog is preinstalled in my ubuntu os, I still prefer feh coz it can be closed by q while eog and xdg-open can be closed by esc .
Commented Jun 30, 2016 at 13:17 Actually, feh does have zoom, fullscreen, scroll etc. look at the man page Commented Sep 11, 2016 at 6:31@pikachuchameleon you'll need to set up an X11 environment and forwarding. Have a look at these instructions
Commented Apr 2, 2018 at 17:27If you happen to have installed imagemagick, you can use its very handy display command-line tool.
display path/to/picture.png
answered Oct 21, 2014 at 12:19
Alexander Popov Alexander Popov
1,831 1 1 gold badge 12 12 silver badges 6 6 bronze badges
I personally prefer feh , but display is usually installed on web servers, where feh or other image browsers aren't installed.
Commented Dec 7, 2014 at 19:34display works great on Ubuntu 16.04 LTS Desktop and also on stock Raspbian. No installs required. TNX from 2017
Commented Jul 22, 2017 at 19:55 Great, works even with stream: curl https://example.com/image.jpg | display Commented Feb 16, 2018 at 21:26to install imagemagick, sudo apt install imagemagick-6.q16hdri , I used it to open .ppm file, display path/to/file.ppm
Commented Jul 18, 2022 at 16:06Display can be fast, but often is not. My benchmark results: display averages 25925ms. feh averages 19.9ms.
Commented Jan 12 at 11:26I usually run python -m http.server 8080 (in python2: python -m SimpleHTTPServer 8080 ) from a folder containing the image and view it from the browser at localhost:8080/path/to/image.jpg. Works great to browse and look at different image and text files in that same directory.
Edit: This method also works for remote boxes. Just run the python server as above, and if the ports are open you can connect to myserver.com:8080/path/to/image.jpg. If the server does not expose ports, you can set up an ssh tunnel with ssh [email protected] -N -L localhost:8080:localhost:8080 and then view the images from your local browser at localhost:8080/path/to/image.jpg. Note this http interface is much faster than ssh -X.
103 3 3 bronze badges answered Feb 1, 2015 at 23:05 RussellStewart RussellStewart 1,891 1 1 gold badge 12 12 silver badges 5 5 bronze badgesClever! Works like a charm and there's no need to type /path/to/image.jpg . Just open localhost:8080 and click on the filenames.
Commented Mar 5, 2015 at 4:49Regarding the last paragraph, you can also add tunnels easily using PuTTY configuration! Then you can access it through a browser. Awesome!
Commented Oct 30, 2015 at 8:45 I needed python -m http.server with Python 3 Commented Sep 8, 2016 at 21:34 x-www-browser /path/to/image or firefox /path/to/image Commented Jun 2, 2017 at 9:08 awesome trick! exactly what i was looking for. Commented Dec 2, 2018 at 12:26I have created a tool that uses various unicode block graphics characters to improve the resolution (compared to the canonical 2 pixel per characterapproach taken by other solutions posted here). It also automatically displays images in a thumbnail mode if multiple images are provided as input.
git clone https://github.com/stefanhaustein/TerminalImageViewer.git cd TerminalImageViewer/src/main/cpp make sudo make install
Not sure why the downvote, guess because of self-promotion? I think it's the best tool for the job though and the question is still relevant today.
Commented Jul 9, 2017 at 22:39It's a pity it doesn't work with apt install . Perhaps time to make a ppa? In any case, this package worked for me, while none of the others did (perhaps I used them in a wrong way). I needed to be able to view images in terminal (for instance, when I'm inside a Docker container) and not to call an image viewer from terminal. Thank you for your answer and I can only thank you more for creating this small, but valuable package!
Commented Nov 2, 2018 at 10:44a snap will be easier for everybody: no ppa to setup for you, no ppa to add for the user -> snapcraft.io
Commented Nov 2, 2018 at 15:56 Does not compile on Ubuntu 16.04 with gcc Commented Mar 20, 2020 at 7:31 @MehdiLAMRANI please file an issue on github with os/compiler/platform details Commented Apr 21, 2020 at 8:06No dependencies, one C file, one header file: imcat
Works on linux, macos, windows. Automatically scales to terminal width, with quality down-sampling.
Because it is a repository on github. clone the repository on your PC and type 'make' in the folder, that you have downloaded
Commented Nov 14, 2020 at 22:37@SridharSarnobat For now you can build from source, or get a pre compiled package using apt if you use my PPA.
Commented Nov 14, 2022 at 16:12Thanks for the response. Hmmmm, I'm having some issues with your repos getting ignored even when I use sudo apt-get update --allow-insecure-repositories . But I was able to build from source (I wish all build from sources were this easy!). I'll have to see whether it causes memory leaks like iTerm's image viewer. Thank you for creating this.
Commented Nov 16, 2022 at 20:03 I find it to be unusable cause the quality is so low, I can't see anything in my plots Commented Aug 5, 2023 at 13:03I guess feh would be the one you are looking for.
Although popping out a terminal-like window for picture display as mplayer does for video playing, Feh is still considered as a terminal-based picture viewer due to its command-intensive control style.
answered Mar 23, 2014 at 5:32 Chenming Zhang Chenming Zhang 1,047 1 1 gold badge 12 12 silver badges 14 14 bronze badgesIf you're in pure terminal with framebuffer activated, I'd recommend fbi. It's always in my after-install to do list.
Otherwise, eog is the default picture opener in Gnome, as Kevin mentioned. Also, Shotwell seems to open pretty fast for me. I'm pretty sure there are hundreds. :-)
123 5 5 bronze badges answered Mar 29, 2012 at 22:47 1,251 1 1 gold badge 17 17 silver badges 24 24 bronze badgesThanks for this one - it's news to me. As an aside, googling lands me at fim's (self-styled framebuffer image viewer improved ) manpage only a few search results in. Dont know yet the difference.
Commented Mar 23, 2014 at 6:42 Damn, it doesn't work over ssh. I get not a linux console Commented Jun 13, 2022 at 4:56If you're on OS X, iTerm 2 supports displaying inline images:
As you can imagine, this can be highly useful when you just want to display an image without going in and opening up Preview.app or having to open the Finder to the image and hitting spacebar on the image.
The feature is documented at iTerm2's feature page
answered Sep 6, 2015 at 2:42 344 3 3 silver badges 5 5 bronze badges It's really laggy in my experience. Commented Mar 11, 2018 at 2:22 Works fine for me. No issues with lag. MBP/OSX 10.12.6 Commented Sep 21, 2018 at 19:00 Could you please benchmark this so we can compare and see which method is the fastest? Commented Jan 12 at 11:30Surprised that the Terminology terminal emulator is not among the answers. As easy as tyls and then clicking on an image:
or someting like tycat image.png , for example:
Plus a lot more. An old video, almost 3 years ago, demonstrating Terminology 0.3: https://www.youtube.com/watch?v=ibPziLRGvkg#action=share.
answered Sep 13, 2016 at 19:34 Nikos Alexandris Nikos Alexandris 1,490 2 2 gold badges 18 18 silver badges 42 42 bronze badgesIf you need to view a single known image, tacat or typop are preferred. First one will embed image into terminal output, second will show it in popup window.
Commented Mar 26, 2021 at 18:51 Great suggestion. If only it worked more smoothly over ssh X11. Commented Jun 13, 2022 at 4:55 Could you please benchmark this so we can compare and see which method is the fastest? Commented Jan 12 at 11:31No real benchmark, but ls -l rekx_draft_logo_72dpi.png : .. 136914 and file rekx_draft_logo_72dpi.png : rekx_draft_logo_72dpi.png: PNG image data, 500 x 500, 16-bit/color RGBA, interlaced . With time tycat rekx_draft_logo_72dpi.png it takes real 0m0,027s, user 0m0,008s, sys 0m0,016s .
Commented Jan 17 at 18:45The kitty terminal can display inside the terminal with the icat "kitten"
kitty +kitten icat /path/to/image
The kitty documentation suggests creating an alias, e.g.
alias icat="kitty +kitten icat"
So that then you can simply do:
answered Feb 5, 2019 at 17:15 8,931 1 1 gold badge 36 36 silver badges 34 34 bronze badgesCould you please benchmark this so we can compare and see which method is the fastest? The usertime reported by the time should work here.
Commented Jan 12 at 11:32w3m's imgdisplay library is able to display images directly. It only works on some terminal emulators such as Xterm and URxvt.
ranger is a file browser that makes use of the library to display previews. Add this to ranger's configuration file to enable the feature:
set preview_images true
answered Oct 21, 2014 at 13:26
384 2 2 silver badges 5 5 bronze badges
Could you please benchmark these so we can compare and see which method is the fastest?
Commented Jan 12 at 11:33
From the terminal? Why not in the terminal: cacaview might be the fastest. By default it's fastest if the terminal has no graphics.
In Debian: sudo apt-get install caca-utils
answered Apr 12, 2016 at 23:42 7,273 4 4 gold badges 24 24 silver badges 53 53 bronze badgesActually, there is a way to show a PNG file in a terminal in text-mode, using picture-tube:
You can look at the project on GitHub.
The image is of course an approximation of the actual image, given the fact that the smallest pixel is a character - try to have a look at the result in a text editor, you will see a huge number of color codes.
You can install the tool like this (assuming you have already installed node/npm): npm install -g picture-tube
247 2 2 silver badges 8 8 bronze badges answered Feb 9, 2017 at 8:14 201 3 3 silver badges 6 6 bronze badgesThere is a tool here called catimg that works really well:
answered Jun 29, 2017 at 2:29 223 2 2 silver badges 5 5 bronze badgesAnother great terminal-based picture viewer is fim, which is a improved fbi with a vim-like control system.
answered Mar 23, 2014 at 11:47 Chenming Zhang Chenming Zhang 1,047 1 1 gold badge 12 12 silver badges 14 14 bronze badges Good solution, but didn't show a way to do it. Commented May 18, 2019 at 22:27I tried this. It opens a separate X window over SSH in case anyone's wondering. What would be ideal for me is an inline terminal display that works over SSH but I don't think there is a good one.
Commented Sep 3, 2019 at 20:51The Ranger file manager enabling the image-preview in settings.
answered Jul 11, 2019 at 12:38 61 1 1 silver badge 1 1 bronze badge Ranger was already mentioned 5 years earlier Commented Dec 22, 2022 at 12:09and ranger appears to launch another program, it may work with inline, but I see it running the default image viewer: feh or imageviewer
Commented Mar 29, 2023 at 11:31In linux you can install gnome-open.
# In Debian flavors sudo apt-get install gnome-open
Then create an alias:
alias open='gnome-open'
open file.pdf open file.jpg etc
answered Dec 8, 2015 at 20:14
Tulains Córdova Tulains Córdova
3,256 4 4 gold badges 20 20 silver badges 27 27 bronze badges
This was installed by default in my Ubuntu install.
Commented Mar 12, 2016 at 11:02
This is a 4 year-old-question but I found that people still look at it. So, today I would like to answer my own question specifically only for iTerm2 .
At first time I asked this question. The term of "fastest" I was thinking of viewing image as fast as cat command displaying text. So, today I found the answer on iTerm2 , which are the two handy commands name imgcat and imgls .
To use them, the first let's install iterm2-nigthly :
$ brew cask install iterm2-nightly
then visit the website:
and install imgcat and imgls commands:
$ go install github.com/olivere/iterm2-imagetools/cmd/imgcat $ go install github.com/olivere/iterm2-imagetools/cmd/imgls
So, I really love them and also hope this will be useful for you all!
answered Apr 11, 2016 at 13:24 5,137 6 6 gold badges 26 26 silver badges 31 31 bronze badgesThis is very useful, so thanks for answering this 4 years later. Works like a charm, but might want to include the install go step ( brew install go ) for those that don't have it yet.
Commented Aug 1, 2016 at 3:17@jamescampbell, you don't need to install go to get the imgcat and imgls scripts. They're provided to you by iTerm's developer himself here: iterm2.com/documentation-images.html, and these are bash scripts.
Commented Nov 23, 2016 at 17:48 what is the closest option to imgcat on Linux? I'm trying to switch atm Commented Jul 18, 2018 at 19:24 Could you please benchmark this so we can compare and see which method is the fastest? Commented Jan 12 at 11:41You can also use chafa (on GitHub). It has a gallery with plenty of examples, showing different options. It even supports animated GIFs.
answered Nov 22, 2020 at 22:08 Denilson Sá Maia Denilson Sá Maia 1,873 2 2 gold badges 16 16 silver badges 15 15 bronze badgespxl is a pretty cool option which hasn't been mentioned yet. Similar to picture-tube which was previously posted in that it shows the image directly in the terminal although it supports more image formats.
answered Mar 16, 2017 at 17:54 Michael Mior Michael Mior 247 2 2 silver badges 8 8 bronze badgesI just use the Chrome webrowser, which supports jpg , svg , png , ico , animated gif . basically everything I'm likely to need:
google-chrome ./myphoto.jpg
If you prefer Firefox:
firefox ./myphoto.jpg
answered Aug 25, 2017 at 15:29
user207863 user207863
149 3 3 bronze badges
Could you please benchmark this so we can compare and see which method is the fastest globally?
Commented Jan 12 at 11:42
Fast, convenient, and easy to use.
$ img2sixel
To install (ubuntu 18.04):
$ sudo apt install libsixel-bin
Example (scaled down to 400 pixels wide with -w 400):
There's a list of terminal requirements in the link, but it's worked with any terminal I've tried it on. I won't bother listing all the supported terminals, but here are some:
answered Oct 9, 2020 at 1:15 21 1 1 bronze badge This worked for me the best and it actually printed in a legible resolution. Commented Sep 22, 2021 at 19:24DEC VT series, VT240/VT241/VT330/VT340/VT282/VT284/VT286/VT382
DECterm(dxterm)
Kermit
ZSTEM 340
WRQ Reflection
RLogin
mlterm
Works on each of X, WIN32 GDI, framebuffer, Android, Cocoa version.
XTerm (compiled with --enable-sixel-graphics option)
yaft
Mintty (>= 2.6.0)
If you have any relatively recent version of ImageMagick, you can output images to any terminal emulator that supports the SIXEL format. This is different from the ImageMagick display command, as the latter requires an X11 session and spawns a separate window, while the former works with any supported terminal, even over SSH. The following command takes an input image, converts it to a SIXEL image, and outputs it to stdout so the terminal emulator can render it:
convert input.png six:-
Sample image: Andy Reago & Chrissy McClarren, CC BY 2.0, via Wikimedia Commons
I just found this page, and it is still very relevant today. OP didn't really specify if they want X or fb viewer.
Needs X, so call from command line in a terminal window. Views many picture formats, gif and jpg for sure. some others as well.
Can do wildcard globbing from command line: eg. "$ pho img00. jpg" will view all files that match in order. Space goes forward through list and backspace goes back. Its quick loading individual images -- hold down space and you fly through them.
Very fast if you want to look through a bunch of pictures, flag ones of interest, rotate, delete unwanted. I keep coming back to it.
From the web page above:
answered Apr 13, 2016 at 14:52 11 1 1 bronze badge Could you please benchmark this so we can compare and see which method is the fastest? Commented Jan 12 at 11:43pho (pronounced like the first syllable in "photo") is a lightweight program for viewing large numbers of images quickly, rotating or deleting some, and making notes about what to do with each image -- for instance, for going through hundreds of images after uploading them from a digital camera.
Even tough there are great answers given, my issue was to view images in terminal itself, without openning any graphical application, so i wrote my own little script. I only needed to identify the image and did not need al the details of it and did not want to download any relatively big packet, if anyone needs they can also use it: https://github.com/Deniz97/terminal-image-viewer
answered Jan 26, 2017 at 19:44 Deniz Uluğ Deniz Uluğ 11 2 2 bronze badgesI have a shell alias for macOS called preview that can (1) display an image inline ( -i or --inline option), either from stdin or specified filepath(s), and (2) just open an image in Apple's Preview app (without any option), the latter also either from stdin or filepath(s), e.g.:
cat image.jpg | preview
preview -i image.png
Inline display only works with the iTerm imgcat alias, so you need iTerm installed, running, and frontmost. But preview checks if all that is true.
answered Aug 22, 2017 at 17:30 131 4 4 bronze badgesTo determine the fastest, we must measure the time. Here are my times for opening and displaying a 700x500 pixel png benchmark image. I took 10 samples for each program. I'm using Ubuntu22.04 from Win11/WSLg with a 12th Gen Intel core i7-12800H. All times are in milliseconds.
Program | avg | min | max | stdev | Measurement method | comment |
---|---|---|---|---|---|---|
feh | 19.9 | 11 | 24 | 5.1 | user time | WINNER |
catimg | 24.3 | 23 | 26 | 1.0 | realtime | low resolution, in-terminal |
dillo | 27.0 | 16 | 36 | 6.8 | user time | but must manually maximize window |
tiv default | 105.0 | 95 | 113 | 5.4 | realtime | 5x10px thumbnail in terminal. 390MB brew download! |
tiv -h 50 -w 150 | 132.3 | 117 | 156 | 11.1 | realtime | comperable to catimg but with compression artifacts. 390MB brew download! |
eog | 333.3 | 206 | 631 | 158.3 | user time | yet nice |
picture-tube | 1377.2 | 1321 | 1448 | 43.2 | wristwatch | terrible image quality, opens seperate window |
gimp | 1422.1 | 1333 | 1483 | 57.5 | user time+system time | opens gimp, then loads image. These may be underestimated by 30-50%. |
nautilus | 2633.3 | 2000 | 3500 | 522.0 | wristwatch | only get thunbnail |
ffplay | 3055.6 | 2500 | 4000 | 583.3 | wristwatch | needs pipe to dev/null |
display | 25925.6 | 57 | 98000 | 34239.5 | user time, wristwatch | UI buttons don't work |
cacaview | 317888.9 | 5000 | 2748000 | 911341.2 | wristwatch | terrible image quality, opens seperate window |
What is a best way to view pictures (like you see images thumbnail in Nautilus) when you are working in the terminal [. ] ?
This part of the question about previewing multiple images at once has not yet been addressed properly. Most image viewers (with the exception of TerminalImageViewer) will not show multiple thumbnails when called with multiple image files. They might display them in a slideshow, which is not always practical (e.g. when browsing through icons).
As a solution, I use a usual file manager in "thumbnail" mode to display all images that I copied to a temporary directory. For example, to display all icons from the KDE icon theme "Breeze" where the filename matches *search* :
tmpdir=$(mktemp -d -t image-previews-XXXXX) find /usr/share/icons/breeze -name "*search*" -exec \ bash -c ' tmpdir=$1; file=$2; newfile=$; newfile=$; cp $file $tmpdir/$newfile ' _ $tmpdir <> \; pcmanfm-qt $tmpdir
This find s and copies all Breeze icons matching *search* to a temporary directory, replacing the path relative to the Breeze installation directory with a filename that has - instead of the directory separator / . This way, the files are all in one directory for previewing, and won't overwrite each other.
Then this starts a file manager (here pcmanfm-qt ) to show the files in the temporary directory. After it starts, it has to be manually set to thumbnail view for best results. Unlike other image viewers, file managers usually can render SVGs into preview thumbnails.
The find command uses a technique with positional parameters in a subshell to allow executing multiple commands in find including variable evaluation, as documented here.