May 22, 2006

CLI Magic: Viewing pictures on the console with fbida

Author: Manolis Tzanidakis

User Level: Beginner to intermediate

Fbida (previously known as fbi) is an image viewer for the Linux console. Some people -- console veterans included -- might find the idea of viewing pictures on the console a little bit silly; why not just use X Windows and a graphical viewer or even a photo editor? The answer to that question varies from "running X on my server is not an option, but I'd like to be able to view some pictures while I'm waiting for the compilation of a new kernel to finish" to "because I can." Pick your excuse and read on to find out more about fbida.

Linux's frame buffer console (fbcon) is a text console with some graphical features, such as support for higher resolutions, varying font types, and display rotation. Most modern Linux distributions have the frame buffer console enabled by default. In case you see one or more penguins on the top of your screen during boot, then your system supports frame buffer.

You can configure the resolution of the console using the vga= boot option parameter, which takes a hexadecimal value. The following values are supported by the generic VESA driver, which supports most graphics cards:

res/col | 640x480  800x600  1024x768 1280x1024
--------+-------------------------------------
256     |  0x301    0x303    0x305    0x307
32K     |  0x310    0x313    0x316    0x319
64K     |  0x311    0x314    0x317    0x31A
16M     |  0x312    0x315    0x318    0x31B

Thus, to get a resolution of 1024x768 with 64K color depth, the option would be vga=0x317.

To pass the vga= option to your kernel using a boot loader, add it to the end of the kernel line in /boot/grub/menu.lst for GRUB, or to the append= line in /etc/lilo.conf if you prefer LILO; for more information on how to configure the boot loader, check the GRUB info page and the lilo.conf man page, respectively. Documentation about the frame buffer can be found in the Documentation/fb directory of any Linux kernel source.

Installation

Fbida is actually two programs: fbi, for viewing pictures on the console, and ida, which does the same thing under X and has an interface based on OpenMotif. Pre-built packages for fbida are available for most distributions. Debian splits fbida into fbi and ida packages.

Installing fbida from source is a bit different than the usual ./configure; make; make install, but it's not that difficult either. First run make Make.config to create the Make.config file based on libraries found on your system. To disable or enable a particular feature, edit Make.config and change the HAVE_SOMETHING value to either yes or no. For example, to disable the installation of ida, change the value of HAVE_MOTIF to no. When you're done with the configuration, run make CC=gcc to compile the program and make install (as root) to install it.

Usage

Running fbida is straightforward; log in to a virtual terminal in console, switch to a directory containing image files, and run fbi *. If the directory contains non-image files, fbi will complain that it can't open them; you can combine fbi with find, file, grep and some console magic to avoid that. Just run:

fbi `find . -exec file {} \; | grep image | cut -d : -f 1`

To switch to the next or previous image, press PgDn (or space) or PgUp respectively. If you want to jump directly to a specific image, enter the image number followed by g; for example, to jump to the seventeenth image on the slide show, press 17g.

Pressing H inside the program prints a help text with all available keys. fbi -h prints a list of the options you can pass to the program, such as the timeout for slide shows or gamma correction. One option I find useful is fbi's auto-zoom feature (enabled with the -a switch), which automatically picks a reasonable zoom factor when loading an image. To store the options in the program's configuration file under $HOME/.fbirc, run fbi with the switches you want, along with -store.

Fbi also provides some basic editing facilities, such as rotating JPEG images 90 degrees and deleting images. To start fbi in editing mode, use the -e switch, and to play it safe you can also use the -b to create backups of the edited images.

For more information about using fbi, check its man page.

Fbida is one of the programs that makes you wonder how you ever lived without them. It's a fast, elegant, and most of all, geeky way to view images on your computer. If only it had a less scary name.

Click Here!