How to display images in terminal in Linux

There are many GUI image viewers for Linux. But we haven’t heard of applications that display photos in the terminal itself. Luckily we found CLI image viewers named FIMwhich can be used to display images in the terminal. The FIM utility is worth paying attention to because it is very lightweight compared to most GUI image viewer applications. Let’s see what he’s capable of.

Displaying images in the Terminal using FIM

FIM means Fbi IMproved. For those who don’t know Fbi in Linux framebuffer imageviewer. It uses the system’s video buffer to display images directly from the command line. By default, BMP, GIF, JPEG, PPhotoCD, png, ppm, tiff and XWD are displayed on the terminal itself. For other formats, it will try to use ImageMagick.

FIM is based on Fbi and is highly customizable and scripted image viewer targeted at users who are familiar with software like Vim text editor or Mutt mail user agent. It displays images in full screen mode, and images can be controlled (such as resizing, scaling, etc.) with a keyboard shortcut. Unlike Fbi, FIM is versatile: it can open many file formats and can display images in the following video modes:

  • Graphically, with a Linux framebuffer device.
  • Graphical for X / Xorg using SDL library.
  • Graphical for X / Xorg using the Imlib2 library.
  • Rendered in ASCII Art in any text console using the AAlib library.

FIM is completely free and open source.

Installing FIM

FIM Image Viewer is available in the default repository of DEB based systems such as Ubuntu, Linux Mint. Thus, you can install the FBI with the command:

$ sudo apt-get install fim

If it is not available in the default repository of your Linux distribution, you can download, build and install from source as shown below.

wget http://download.savannah.nongnu.org/releases/fbi-improved/fim-0.6-trunk.tar.gz
wget http://download.savannah.nongnu.org/releases/fbi-improved/fim-0.6-trunk.tar.gz.sig
gpg --search 'dezperado autistici org'
# import the key from a trusted keyserver by following on screen instructions
gpg --verify fim-0.6-trunk.tar.gz.sig
tar xzf fim-0.6-trunk.tar.gz 
cd fim-0.6-trunk 
./configure --help=short 
# read the ./configure --help=short output: you can give options to ./configure
./configure 
make 
su -c "make install"

Using FIM

After installation, you can display the image with the “auto zoom” option using the command:

$ fim -a dog.jpg

Here is an example of the output from the Ubuntu console

As you can see in the screenshot above, FIM does not use any external GUI image viewers. Instead, it uses our system’s video buffer to display the image.

If you have multiple .jpg files in the current directory, you can use wildcards to open all of them as shown below.

$ fim -a *.jpg

To open all images in a directory, for example images, run the following command:

$ fim Pictures/

We can also open images recursively in a folder and its subfolder and then sort the list as shown below.

$ fim -R Pictures/ --sort

In order to render the image in ASCII format, you can use the flag -t

$ fim -t dog.jpg

To exit FIM, press ESC or q.

Hotkeys

You can use various keyboard shortcuts to manipulate images. For example, to download the next image and previous images, press PgUp / PgDown. Zoom in or out using the +/- buttons. Here are the common keys used to control the image in FIM.

  • PageUp / Down : Previous / Next Photo
  • +/- : Increase / decrease
  • a : Autoscale
  • w : Justified
  • h : Height
  • j / k : down up
  • f / m : Flip / Mirror
  • r / R : Rotate (clockwise and counterclockwise)
  • ESC / q : Exit

For full details see man page

$ man fim

It’s all. Hope this helps. Be in touch!

Sidebar