Linux Commands

How Do I Display an Image in a Linux Terminal?

Did you know our brain interprets images much more swiftly compared to text? Well, Digital media is one of the key elements of computer systems now. Being a Linux user, I try to perform most of the operations through the terminal using commands. The majority of the tasks in the terminal are text-based; I can read, edit text files, but I had no idea how to display images in the terminal. Is it even possible to view images while using the terminal? Well, luckily, the answer is yes! Images can appear in the terminal using commands.

There are various GUI-based applications in Linux distributions to view images, but many Linux users prefer to work with the terminal. This guide is going to mention few techniques to display images in the terminal. These methods would be quite helpful for those who are searching for CLI (Command Line Interface) based applications to view images.  So, let’s begin:

How to display images in terminal through FIM

The first method to view pictures in the terminal is FIM, an open-source, highly customizable image viewer application. FIM represents Fbi IMproved, and Fbi is “frame buffer image viewer” in Linux. FIM is lightweight compared to many GUI-based applications and comes with various shortcut keys to control images. Common file formats FIM supports are jpeg, png, gif, ppm, tiff, and xwd. To install it, use the commands mentioned below:

For Ubuntu and Debian based distros, FIM can be installed using:

$sudo apt install fim

The syntax to display image in terminal is:

$fim -a [name_of_image]

Now, to display the image in the terminal, use:

$fim -a image1.jpg

To display all the images of the same extension, use:

$fim -a *.jpg

The keyboard shortcuts to control image are listed below:

  • Image Navigation : PageUp & PageDown or “Enter”
  • Zoom : +\-
  • Autoscale: a
  • Fitting width and height: w\h
  • Flip: f
  • Mirror: m
  • Rotate (clockwise) : r
  • Rotate (anti-clockwise) : R
  • To quit FIM, press the “Esc” or “q” key.

How to display images in terminal using ImageMagick

Most Linux users are aware of the “ImageMagic” utility. It is a lightweight application to manipulate images of hundreds of formats, including jpeg, png, gif, pdf, svg, etc. It can even convert the images from one format to another.

But many of us don’t know that there is a command associated with this app called the “display” command. Using the “display” command, you can view the image in the terminal. To install it, use the below-mentioned commands:

For Ubuntu/Debian based distros:

$sudo apt install ImageMagick

For CentOS 8, Red Hat (RHEL), and Fedora:

$sudo dnf install -y ImageMagick ImageMagick-devel

For OpenSUSE:

$sudo zipper install -y ImageMagick

To display an image in terminal use:

$display image1.jpg

And to close the image, press the “Esc” or “q” key. To specify the size of the images, use the “-geometry” option with the “display” command:

$display -geometry 600x400 image1.jpg

To manipulate the size of the image, use the “-resize” option:

$display -resize 800x500 image1.jpg

Or use “%” sign with “-resize” flag:

$display -resize 60% image1.jpg

How to display images in terminal using feh

“Feh” is another lightweight image viewer application designed to view images in the terminal. It not only displays images from your local drive but also from the internet through URLs. You can browse images in various forms such as montages, slideshows, thumbnails, etc. To install it on Linux, use the commands listed below:

For Ubuntu and Debian based distros:

$sudo apt install feh

To install it on Arch Linux:

$sudo pacman -S feh

To install it on FreeBSD and OpenBSD:

$pkg install feh

Once the installation is done, you can view the image using the command given below; I am displaying “image1.jpg” from the “Downloads” directory:

$feh image1.jpg

To run a slideshow, open the terminal in the directory containing images and execute:

$feh

To navigate images, use “left/right” arrow keys and zoom in and zoom out using “up/down” keys. To view more than one image on the screen, especially in montage format, use the “-m” (montage) option:

$feh -m

To open multiple images in multiple windows, use:

$feh -w

To quit, simply press the “Esc” key.

How to display images in terminal using Terminology

Images can also be viewed in a terminal emulator called “Terminology.” This feature-rich terminal emulator not only displays images in the terminal but also plays videos in it. To install it on Ubuntu and Debian based distributions, use:

$sudo apt install terminology

To install it on Arch Linux:

$sudo pacman -S terminology

To install it on Fedora, use: 

$sudo dnf install terminology

For OpenSUSE, execute:

$sudo zypper install terminology

And to view to image, follow the syntax:

$tycat [image_file_name]

For instance:

$tycat image1.jpg

To play video, use:

$typop [video_file_name]

Terminology is one of the well-known terminal emulators and comes with tons of features and customization options.

Conclusion

Viewing digital media such as images/animated gifs in the terminal can be much more convenient for Linux users who spend most of their time working with the terminal. It can be helpful in various ways. We discussed four different approaches to display images in the terminal. But other utilities can help display images in the terminal, such as w3m, viu, and eog (eye of gnome). The terminal is an effective way to communicate with your system, and displaying digital media in the terminal enhances its functionality and helps the terminal users work more efficiently.

About the author

Sam U

I am a professional graphics designer with over 6 years of experience. Currently doing research in virtual reality, augmented reality and mixed reality.
I hardly watch movies but love to read tech related books and articles.