How To Use Feh For Raspberry Pi

In the mood for a small, lightweight image viewer for use in the Raspberry Pi Terminal? Then feh may well be the package you’re looking for.

There are countless image viewers available for Linux, and as such the Raspberry Pi. Some offer enhanced modes, editing features, or a collection of filters, some though are just simple and easy to use; lightweight, but also capable of a surprising number of options. Feh is one such tool.

Feh is a lightweight, configurable and versatile image viewer. It is aimed at command line users, but can also be started from graphical file managers. Apart from viewing images, it can compile text and thumbnail listings, show (un)loadable files, set X11 backgrounds, and more.

Installation

Feh isn’t installed by default on the Raspberry Pi, so you’re going to need to drop into a Terminal and enter the following:

sudo apt-get install feh

The installation won’t take long, and if you’re asked to update anything or accept changes then answer ‘y’ to continue.

Once installed, navigate to a folder with images and simply enter: feh into the Terminal. The default feh window will begin to slideshow all the images you have in the folder you’ve executed feh in, simple press the left or right arrow keys to advance or scroll your mouse wheel.

You may notice that some of the images are too large for the feh window to display, if that’s the case you can close the current feh window and run the following in the Terminal:

feh --scale-down --auto-zoom

The images should now be displayed correctly.

Options, options and more options

Feh has an impressive number of options available via flags after the main command. For example:

feh -m

Will launch a new window displaying a montage of the images in the current folder, you can then right-click each of the images to display further options and information regarding the image. Whereas:

feh -w

Will launch all the images within the folder as separate Feh windows; make sure you don’t have too many images in the folder before doing this.

feh --randomize

Will randomise the files in the slideshow. While:

feh --reverse

Will reverse the order of the image files to be displayed.

There’s not enough room here to go into detail of all the options, so to browse through them yourself enter:

man feh

Which launches the Man pages for Feh.

Since this is a Linux command, it’s quite easy to include Feh in your Bash scripts or Python code. For example, if you wanted Feh to display some images from Python (make sure you’ve got Feh installed first), then you’d use the following:

import os

cmd=”feh --scale-down --auto-zoom ~/Pictures/”

os.system(cmd)

Change the directory in the cmd value to where the images are stored (we’ve used ~/Pictures/ here), save the Python code as fehpy.py, and run the command from the Terminal with:

python3 fehpy.py.

Conclusion

Feh isn’t the best image viewer available to the Raspberry Pi, but it’s pretty good. If you want a quick and easy solution to viewing images via the Terminal, then running Feh on its own, or through a Python or Bash script will do the job well enough.

Find more guides like this in…

David Hayward

David has spent most of his life tinkering with technology, from the ZX Spectrum, getting his hands on a Fujitsu VPP5000/100 supercomputer, and coding on an overheating Raspberry Pi. He's written for the likes of Micro Mart, Den of Geek, and countless retro sites and publications, covering reviews, creating code and bench testing the latest tech. He also has a huge collection of cables.

Related Articles

Back to top button
Close