So, yesterday I and some disgusting friends got together and discussed the possibilities of a Linux terminal application. It all came down to what we have ever done using our command line. One friend mentioned that he played gifs “in” the terminal. If he said “through” the terminal, that would not be a big deal, but the way he played them in the terminal fascinated us. This was the GIF-for-CLI application that he used to do this; it plays GIFs in ASCII format only – obviously, they look in very low resolution and are hardly distinguishable. I tried the trick with different GIFs and came to the conclusion that only some animated GIFs can be viewed and interpreted correctly on the Linux command line. Therefore, you cannot rely on this trick, but you should try it from time to time for fun.
In this article, we will tell you how to install the GIF tool for the CLI on Debian, and view gif files through this tool inside the terminal.
Why command line?
If you are an experienced person, you will not want to leave the command line and go somewhere else to perform any of your daily technical tasks. Almost always there is an opportunity to perform almost all of 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. Command line tools do not consume too many resources, so they are a great alternative to widespread graphical applications, especially if you are stuck on outdated equipment.
We ran the commands and procedures mentioned in this article on the Debian 10 Buster system.
Setting GIF-for-CLI via command line
You can install the Gif tool for the CLI using the Python 3 and pip installation tools. Open the Terminal application by pressing the Super key (Windows) and searching the Application Launcher as follows:
Log in as sudo or as root (by typing su and then the password for root). You are now authorized to add / remove and configure software in Debian. Now enter the following command to update the local repository index on the Internet. This will help you install the latest software available online.
# sudo apt-get update
Here are some of the dependencies you need to install before starting the installation of 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 be installed on your system.
Remove Gif for CLI
If you ever want to remove Gif for the CLI installed using this method, you can use the following command in the terminal as root:
# pip3 uninstall gif-for-cli
Using Gif for CLI to view pictures
GIF for cli accepts a GIF, short video, or request to the Tenor GIF API and converts it to ASCII animated graphics. Animation and color support are performed using ANSI escape sequences.
Open a Terminal application and use the following syntax to play the GIF file using the installed Python module:
# python3 -m gif_for_cli path/to/some.gif
I switched to Pictures and then played back a file called sample.gif as follows:
# python3 -m gif_for_cli sample.gif
This script will automatically determine how many colors the current terminal is using and display the correct version.
Here’s what my original GIF looks like:
And here is what it looks like when I play in the Terminal:
To call it “close enough” would be an exaggeration.
In the end, it was a fun trick, and I would rather watch my gifs through the user interface using all modern image and video players.
Just for fun: show gifs as text in a Debian terminal