So yesterday me and some geeky friends sat together and discussed the power of the Linux terminal application. It came down to what the geekiest or terminal savvy thing we ever did with our command line. One friend mentioned that he played gifs “in” the terminal. If he had said “through” the terminal, it wouldn’t have been a big deal, but how he played them in the terminal fascinated us. It was the GIF-for-CLI application he had used for this; it plays GIFs in ASCII format only – obviously they seem to be in very low resolution and are hardly visible. I tried the trick with different GIFs and came to the conclusion that only some animated GIFs could be viewed and fairly interpreted on the Linux command line. Therefore this trick is not something you can rely on, but you should try it from time to time just for fun.
In this article we will explain how to install the GIF for CLI tool on your Debian and view gifs via this tool inside the terminal.
Why the command line?
If you are a terminal savvy person, you would not want to leave the comfort of the command line and go somewhere else to do any of your daily technical activities. There is always a way to do almost all our tasks directly in the terminal. So why should the gif display be different! Using the terminal makes certain tasks more efficient and even faster. The command-line tools don’t consume too many resources, so they are a great alternative to the widespread graphical applications, especially if you are stuck with older hardware.
We have run the commands and procedures mentioned in this article on a Debian 10 Buster system.
Installing GIF-for-CLI through the Command Line
You can install the Gif for CLI tool via Python 3 setup tools and pip. Open the Terminal application by pressing the Super(Windows) key and searching for it through the Application Launcher as follows:
Login as sudo or as root(by entering su and then the password for root). You are now authorized to add/remove and configure software on Debian. Now, enter the following command in order to update the local repository index with that of the Internet. This helps you in installing the latest version of a software available online.
# sudo apt-get update
These are some of the dependencies that you need to install before heading to install gif-for-cli:
# apt-get install ffmpeg zlib* libjpeg* python3-setuptools
Then install Gif for CLi through pip3 as follows:
# pip3 install --user gif-for-cli
The package will then be installed on your system.
Remove Gif for CLI
If you ever want to remove Gif for CLI installed through this method, you can use the following command in the Terminal as root:
# pip3 uninstall gif-for-cli
Using Gif for CLI to view gifs
The gif for cli takes in a GIF, short video, or a query to the Tenor GIF API and converts it to animated ASCII art. Animation and color support are performed using ANSI escape sequences.
Open the Terminal application and use the following syntax to play a gif by using the installed Python module:
# python3 -m gif_for_cli path/to/some.gif
I switched to Pictures and then played a file named sample.gif as follows:
# python3 -m gif_for_cli sample.gif
This script will automatically detect how many colors the current terminal uses and display the correct version.
This is how my original gif looks like:
And, this is how it looks like when I play it in the Terminal:
Calling it “close enough” would be nothing short of exaggeration.
This, after all, was a fun trick and I would rather watch my gifs through the UI using all the modern image and video players.