Home Command line utilities How To Display Thumbnail Images In Terminal

How To Display Thumbnail Images In Terminal

By sk
Published: Updated: 8.4K views

A while ago, we discussed about Fim and Viu - the CLI image viewer applications used to display various type of images, such as bmp, gif, jpeg, and png etc., from command line. Today, I stumbled upon a similar utility named 'lsix'. It is like 'ls' command in Unix-like systems, but for images only. The lsix is a simple CLI utility designed to display thumbnail images in Terminal using Sixel graphics. For those wondering, Sixel, short for six pixels, is a type of bitmap graphics format. It uses ImageMagick, so almost all file formats supported by imagemagick will work just fine.


Concerning the features of lsix, we can list the following:

  • Automatically detects if your Terminal supports Sixel graphics or not. If your Terminal doesn't support Sixel, it will notify you to enable it.
  • Automatically detects the terminal background color. It uses terminal escape sequences to try to figure out the foreground and background colors of your Terminal application and will display the thumbnails clearly.
  • If there are more images in the directory, usually >21, lsix will display those images one row a a time, so you need not to wait for the entire montage to be created.
  • Works well over SSH, so you can manipulate images stored on your remote web server without much hassle.
  • It supports Non-bitmap graphics, such as.svg, .eps, .pdf, .xcf etc.
  • Written in BASH, so works on almost all Linux distros.

Install lsix in Linux

Since lsix uses ImageMagick, make sure you have installed it.

ImageMagick is available in the default repositories of most Linux distributions. For example, on Arch Linux and its variants like Antergos, Manjaro Linux, ImageMagick can be installed using command:

$ sudo pacman -S imagemagick

On Debian, Ubuntu, Linux Mint:

$ sudo apt-get install imagemagick

lsix doesn't require any installation as it is just a BASH script. Just download it and move it to your $PATH. It's that simple.

Download the latest lsix version from project's github page. I am going to download the lsix archive file using command:

$ wget https://github.com/hackerb9/lsix/archive/master.zip

Extract the downloaded zip file:

$ unzip master.zip

This command will extract all contents into a folder named 'lsix-master'. Copy the lsix binary from this directory to your $PATH, for example /usr/local/bin/.

$ sudo cp lsix-master/lsix /usr/local/bin/

Finally, make the lsbix binary executable:

$ sudo chmod +x /usr/local/bin/lsix

That's it. Now is the time to display thumbnails in the terminal itself.

Before start using lsix, make sure your Terminal supports Sixel graphics.

The developer has developed lsix on an Xterm in vt340 emulation mode. However, the he claims that lsix should work on any Sixel compatible Terminal.

Xterm supports Sixel graphics, but it isn't enabled by default.

You can launch Xterm with Sixel mode enabled using command (from another Terminal):

$ xterm -ti vt340

Alternatively, you can make vt340 the default terminal type for Xterm as described below.

Edit .Xresources file (If it not available, just create it):

$ vi .Xresources

Add the following line:

xterm*decTerminalID    :   vt340

Press ESC and type :wq to save and close the file.

Finally, run the following command to apply the changes:

$ xrdb -merge .Xresources

Now Xterm will start with Sixel mode enabled at every launch by default.

Display Thumbnail Images In Terminal

Launch Xterm (Don't forget to start it with vt340 mode). Here is how Xterm looks like in my system.

xterm window
xterm window

Like I already stated, lsix is very simple utility. It doesn't have any command line flags or configuration files. All you have to do is just pass the path of your file as an argument like below.

$ lsix ostechnix/logo.png
Display thumbnail using lsix
Display thumbnail using lsix

If you run it without path, it will display the thumbnail images in your current working directory. I have few files in a directory named ostechnix.

To display the thumbnails in this directory, just run:

$ lsix
Display thumbnail images using lsix
Display thumbnail images using lsix

See? The thumbnails of all files are displayed in the terminal itself.

If you use 'ls' command, you will just see the filenames only, not thumbnails.

ls command output
ls command output

You can also display a specific image or group of images of a specific type using wildcards.

For example, to display a single image, just mention the full path of the image like below.

$ lsix girl.jpg
Display a single thumbnail image
Display a single thumbnail image

To display all images of a specific type, say PNG, use the wildcard character like below.

$ lsix *.png
Display all images of a specific type
Display all images of a specific type

For JPEG type images, the command would be:

$ lsix *.jpg

The thumbnail image quality is surprisingly good. I thought lsix would just display blurry thumbnails. I was wrong. The thumbnails are clearly visible just like as they appears on the graphical image viewers.

And, that's all for now. As you can see, lsix is very similar to 'ls' command, but it only for displaying thumbnails. If you deal with a lot of images at work, lsix might be quite handy.

Give it a try and let us know your thoughts on this utility in the comment section below. If you know any similar tools, please suggest them as well. I will check and update this guide.


You May Also Like


gazoo January 4, 2019 - 4:10 am

Great series of articles you’ve posted recently re: terminal apps! I’m really enjoying them and taking notes too.

I have to play around with lsix because it turns out I have neither xterm installed (Synaptic tells me it’s available) or imagemagick (I switched distros a couple of months ago to mx18).

The article on FIM… very informative too! Looking forward to trying this out. I need to understand how “framebuffer” can actually display graphics overlayed on a text-based terminal window. Still a newbie but these articles are setting me up on the right path to investigate further.

Recently I can across an article on streaming online radio stations (using mplayer with ffmpeg). There was also the recently posted nugget on ‘scrot’ (the terminal-based screenshot tool). Fun times:-)

I didn’t realize the Linux command-line could be empowered to handle some of the things these articles are focusing on. Looking forward to command-line video options because that would be epic:-)

sk January 4, 2019 - 11:00 am

Thanks for your positive feedback and suggestions. I will try my best to post new and useful topics in the days to come. Have a good day!!


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More