Previous Page
PCLinuxOS Magazine
Article List
Next Page

An Un-feh-gettable Image Viewer

by Paul Arnote (parnote)

There's an image viewer that's been around since 1999 that many Linux users don't know about. I suspect that even many of those who do know of it often forget about it when they are looking for an image viewer. It is called feh. Although not typically part of a PCLinuxOS installation, feh is easily installed via Synaptic.

Despite its odd name, it is a powerful command line utility. It is a X11 viewer aimed mostly at command line users. On its home page, feh bills itself as a "fast and light imlib2 based image viewer." More "enterprising" individuals can easily employ it as a file manager extension on Thunar, Caja and Dolphin/Konqueror, placing a powerful image viewer literally right at their fingertips.

On desktops where the background is not handled by the desktop environment, feh can even be used to control the desktop background wallpaper. Openbox and LXDE, for example, can be set up this way fairly easily since PCFileMan is commonly used on these desktops, and PCFileMan is typically set up to handle displaying the desktop wallpaper. On my computer running Xfce, xfwm controls the wallpaper, so the feh commands to display wallpaper don't seem to have any effect.

You can view the entire man page for feh by entering man feh at a command line, or by viewing the man page online here or here. By looking at the rather in-depth feh man page (1002 lines in a terminal session when you display the man page there), you will discover that feh has many capabilities. For our purposes here, we're just going to cover the basics to introduce you to this powerful program. The man page should be sufficient to help you explore feh's additional capabilities.

Feh can display all the image formats that are supported by imlib2. This includes JPG, PNG, XPM, BMP, GIF, TIFF and TGA files. While primarily a command line program, images are opened in a window (or windows) on your desktop. From there, you can access some of the features of feh from a context menu that is accessed via a right click on the image.

Displaying images with feh is easy. At a command line, simply enter feh <path/to/filename>. But that might not be the most efficient method, especially if you're trying to view the typically large images from modern digital cameras. Feh will display the image at its native size, with the image viewing window full screen. This will mean that you will only see a portion of the image, unless you know how to use the keyboard to tweak the image display.

The keyboard controls are quite easy to use, as well. When faced with the need to zoom out on the displayed image, simply press the up or down arrow keys. The down arrow zooms out, while the up arrow zooms in. To scroll around the image without changing the zoom level, try holding down the CTRL key while pressing the arrow keys. Pressing the ALT key in combination with the arrow keys is akin to pressing the Page Up and Page Down keys in a text document, moving to the next screen's width (or height) viewport in the image. There is a whole list of other available keyboard commands in the feh man page.

Of course, you can exercise further control over how feh displays images by employing some of the feh command line switches. We can alter the command to execute feh so that we have control over the size of the feh image window. Entering the command feh -g <width>x<height> <path/to/filename> will set the feh window to the size specified by <width> and <height> values. By default, feh will also automatically zoom the image to fit it in the specified window size. In fact, the exact command I used to display the image above was feh -g 300x525 1026141605.jpg.

Feh works on directories, too!

If you have your images sorted into directories, you have some other options when using feh. Feh will also offer you some additional capabilities.

If you travel to a directory that contains your images and type just feh at the command line prompt, feh will display each image in that folder, at full size (or 100% zoom). You can also pass a directory path as a command line parameter, if you'd rather not move to the directory containing your images you want to display. This is the feh slideshow mode. You move from image to image by using the left and right cursor keys. With today's camera resolutions, most pictures are too big to fit on your computer screen at 100% zoom. So, just issuing feh, by itself, on the command line prompt isn't going to be all that helpful -- unless all of the images in your directory are already smaller in dimensions than your screen resolution. However, you can regain its usefulness by adding the command line switch -., like this: feh -.. This will still display the feh window taking up all of your screen real estate, but the image displayed will be zoomed to fit the window, with proper proportions. Another option is to display the slideshow in fullscreen mode, without a window around the image. All of the images are automatically zoomed to fit on your screen. You do this by issuing the command feh -F. You will still have the use of the cursor keys to flip through your images. When you are finished viewing your slideshow, tap the "Escape" key to exit feh (the "Escape" key will always close feh). You can automate the slideshow display by adding the --slideshow-delay 5 command line switch. This will display each image in the directory for five seconds. If you want the images to be displayed for a different amount of time (longer or shorter), just change the "5" to however many seconds you want each image displayed. So, the command feh -F --slideshow-delay 5 will display each image in the current directory for five seconds as a fullscreen slideshow.

Feh will also display images from a file list that isn't unlike the *.m3u or *.pls playlists used with music player software. Just list the image files, in the order you want to display them, in a list. The format can be either absolute file paths and names, or filenames relative to the current directory (I suspect that absolute file paths and names would be less confusing than filenames relative to the current directory). Then, issue the command feh -f filelist.lst, replacing filelist.lst with whatever you named the image file list. Of course, you can combine this command line switch with other command line switches, such as the "-." command line switch to display images zoomed out to fit the window. The command feh -F -f filelist.lst --slideshow-delay 5 will display all of the images in filelist.lst as an automated fullscreen slideshow that changes the image every five seconds.

If you want to open up the images in a directory, without the slideshow option but with each image in its own window, you can enter the command as feh --multiwindow -g 300x400. While each image will be in its own window, the windows will be stacked one on top of another. You will have to "peel" them apart, so to speak, moving them off of the top of one another by dragging each window with your mouse to a new location on your screen.

If you type feh -l (that's a lowercase L) at the command prompt (we'll assume you're entering the command at a command prompt IN the directory containing your images), you will get a list of all of the images in the directory, along with each image's file format, dimensions, pixel resolution, and file size. You can easily redirect this output to a file in the directory, if you wish, simply by typing something along the lines of feh -l > image-list.txt.

You can also create a feh "thumbnail mode" window. Feh will display the images in the current directory as thumbnails in a special window, at the sizes you specify. Then, if you click on any image, that image is opened in its own window, at the 100% zoom level. Since this is probably best done from within an image directory, your command might look something like this (entered all on one line):

[parnote-toshiba@localhost RyanGrandpas-Oct2014]$ feh --thumbnails --thumb-height 200 --thumb-width 200 --index-info "%n\n%wx%h" --output thumbnails.png

By saving the output, you have a type of "contact sheet" (that's what we called them when I was a newspaper photographer) or image index. Opening the image (thumbnails.png in our case) in feh or any other image viewer, it behaves like any other image you might open to view. To get the clickable thumbnails again, just repeat the command above.

You can also create a "contact sheet" or image index by using another command line switch. Enter the command like this (all on one line, of course):

[parnote-toshiba@localhost Ryan-Pulling-Up-In-Crib-June-23-2014]$ feh --montage --thumb-height 200 --thumb-width 200 --index-info "%n\n%wx%h" --output montage.png

This command line switch, --montage, is just like the --thumbnails command, except that you don't get the clickable thumbnails. Other than that, and the output filename, you end up with similar results -- just sans the clickable thumbnails. You can limit the width or height of the montage image (the width defaults to 800 pixels), if you choose. I'll refer you to the feh man page (links at the beginning of the article) for a complete list of special feh commands that can be used with the --montage command line switch.


As you can see, the oddly named feh can do quite a lot to help you with your image viewing needs. We haven't covered all of feh's capabilities, but what we've covered here should give you a good start. Some of the other options/capabilities are ones that I feel would only be useful to the true command line commando, like deleting images. There are easier ways to delete image files using a GUI file manager. Plus, you'll want to be extra careful deleting images -- because once they are gone, they are gone.

As a reminder, save yourself a whole lot of pain and anguish by performing irreversible image tasks ONLY on copies of images -- never on the originals.

Previous Page              Top              Next Page