feh – lightweight command line image viewer and data tool

While I was looking for a better image viewer than the default ‘eye of gnome’ (eog from the command line), that’s able to play animated gifs, I came across a command line tool called feh

sudo apt-get install feh

feh is is lightweight image viewer that you can call from the command line. It can recursively view files with the following command for example:

feh -r *.jpg

You can navigate through the images with your arrow keys or space bar and backspace. Use the window close button or press esc to quit.

That’s all good and fun and I’ll probably use it from time to time but it’s not what really got me excited about this tool. It has an option for a “list” of image attributes as the screenshot below shows.

screenshot3

By typing for example

feh -l *.jpg

I would list all attributes for jpgs within a specified directory. In my screenshot, I had a text file multiple image extensions, so I did a subshell with an ‘ls’ command piped to ‘grep -v’ which negates whatever pattern that follows it. To rephrase, the command inside $() is run first and that list which has all files minus those ending in ‘.txt’ is called by the ‘feh -l’ command.

I find this very helpful for when I’m slicing images for web pages. When I’m typing out css for example:

#my_image {
  display:block;
  height:25px;
  width:120px;
  background:transparent url('img/my_image.png') 0 0 no-repeat;
}

it’s very handy to have the image dimensions. The nice thing about this raw dimension output is that I can script it further to generate CSS like above.

There are many other tricks this command can do, just type ‘man feh’ to learn more.

By the way, I’ve started using gThumb as my default image viewer, it’s still lightweight and quite powerful. It’s essentially the same as eog with some minor differences and a few major enhancements

sudo apt-get install gthumb

6 thoughts on “feh – lightweight command line image viewer and data tool

  1. M. Macx

    Thanks! feh will be great for an all-command-line-and-ncurses ubuntu I’ve been wanting to build.

    For the desktop, I really like gqview. Lightweight, lots of features.

    Reply
  2. Conor

    Did you ever find a lightweight image viewer, similar to feh, that displays animated GIFs? Your post seems to imply that feh does this, but I have had different results.

    Reply
    1. Tyler Mulligan

      I’ve been using gThumb which seems to be just slightly more powerful than eog and can be configured to be more or less the same interface. I only use feh for mass dumps of image dimensions that I want to compare.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>