未加星标

How To Display Thumbnail Images In Terminal

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二04 | 时间 2019 | 作者 红领巾 ] 0人收藏点击收藏

A while ago, we discussed about Fim , a lightweight, CLI image viewer application 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 fine.

Features

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. Installing lsix

Since lsix uses ImageMagick, make sure you have installed it. It 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.


How To Display Thumbnail Images In Terminal

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
How To Display Thumbnail Images In Terminal

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
How To Display Thumbnail Images In Terminal

Display thumbnail images using lsix

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

If you use ‘ls’ command, you would just see the filenames only, not thumbnails.


How To Display Thumbnail Images In Terminal

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
How To Display Thumbnail Images In Terminal

Display a single thumbnail image

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

$ lsix *.png
How To Display Thumbnail Images In Terminal

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 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.

More good stuffs to come. Stay tuned!

Cheers!

Resource: lsix GitHub Repository

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

代码区博客精选文章
分页:12
转载请注明
本文标题:How To Display Thumbnail Images In Terminal
本站链接:https://www.codesec.net/view/628019.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(44)