Open Source

How to create photo slideshows with as little software as possible

Marco Fioretti found an easy way to automate to automate complex, portable slideshows by creating them only once and then running them any time you want.

Linux has several digital photograph managers, with feature sets going from "simple but sufficient" to "very rich". Personally, I am a big fan of digiKam. One day, however, I found something that digiKam and -- as far as I know -- all the other GUI photo managers for Linux are missing: a way to script slideshows of photographs.

Of course, in digiKam and all its competitors you can create a slideshow: you select the single galleries or pictures you want, then set the duration of each image, transition effects if available, and so on. The problem is that you can't save those settings anywhere. In other words, you can't save to some file all the commands to restart that specific slideshow. If that were possible, you could type at any moment something like "digikam christmas_slideshow" or "digikam college_slideshow", and digiKam would do the Right Thing, without forcing you to repeat all those clicks.

Another reason why I started thinking about script-based photo slideshows was that I wanted to play them on any Linux-based hardware, from digital picture frames or set-top boxes, to computers that are too old and limited to run modern Linux desktops. I wanted a simple way, that would work everywhere with as little software as possible, to make a generic Linux box, or my USB Live distribution, display a sequence of pictures, full screen. I also wanted something that didn't require programming skills, was distribution-independent, and wouldn't force me to install 50 other packages that may or may not be available on my target box.

The best method I've found is so simple that it doesn't even need the X Window system, not to mention windows or desktop managers, to run. The Frame Buffer Image viewer (fbi) displays files in Jpeg, Gif, PNG and other formats directly on the Linux console, using the framebuffer device (/dev/fb0). If ImageMagick is installed, fbi can use it to handle all the other formats supported by the convert command of that graphic suite. If you want fbi to display, in an endless loop, all the Jpeg files in a given directory, save this code into a file and make it executable:

1 #! /bin/bash
4 fbi -noverbose -a -t $INTERVAL -u `find $PHOTODIR -iname "*.jpg"`

When you launch this script, fbi will display all the Jpeg files found in the folder passed as first argument, sorted in random order (-u), without any caption (-noverbose). Fbi will also change picture every $INTERVAL seconds, autoscaling it to fit the screen without deformations (-a). Adding --comments will display the comments embedded in each file at the bottom of the screen. That's it (but keep reading for more tricks)!

Fbi is very simple to use and comes in binary packages for many Gnu/Linux distributions, so you don't have to compile anything. Since it doesn't require an X server to run, you can install and use fbi even on very limited computers (including devices like the "Free as in Freedom" Raspberry PI), with very little disk space. This, however, doesn't mean you cannot use fbi on your graphic Gnu/Linux desktop!

Linux has Virtual Consoles, accessible with the CTRL+ALT+Fn combination, with n normally going from 1 to 6. Therefore, you don't need to log out of your usual graphic session if you decide to start your slideshow. Just hit |CTRL+ALT+F2| to move to second virtual console, log in, and launch the script. It will be much quicker than starting a program like digiKam and clicking your way through it! Should you want to go back for a moment to the graphic session, without interrupting the slideshow, type CTRL+ALT+F1. The only possible complication of this approach is that fbi requires write access to the framebuffer device. By default, such access is reserved to the root user (on Fedora, at least).

If you want to run the script above with another user ID, you should either set its SUID bit, so it can run with root privileges, or (better) change the permissions of the /dev/fb0 device. If you want to know what these things are, come back next week for my next post!

Choosing and processing the pictures in real time

Let's go back to the last line of the script above:

fbi -noverbose -a -t $INTERVAL -u `find $PHOTODIR -iname "*.jpg

As is, it simply passes to fbi all the Jpeg files found in $PHOTODIR and all its subfolders. You may do much more than that, always using Free Software that doesn't need a graphic environment to run and has as little dependencies as possible. You may, for example, tell find to only return pictures of your 2011 vacations (if you named them properly, of course):

find $PHOTODIR -iname "2011*vacation*.jpg"
You may also create temporary copies of all pictures and process them in all the ways possible with the ImageMagick tools , before telling fbi to display them. I have no space here to explain all the possibilities in detail. I'll just mention that it would be quite easy to add 3D borders , insert text labels or create mosaics , all on the fly. You may even play a soundtrack during the slideshow with mpg123 or similar tools. The basic point, which I hope is clear by now, is that (with the possible exception of sophisticated transitions between pictures), on any Linux system you can create complex, portable slideshows once and then run them as often as you wish, without wasting any more time!


Marco Fioretti is a freelance writer and teacher whose work focuses on the impact of open digital technologies on education, ethics, civil rights, and environmental issues.


Last week I asked Marco for help with regard to fbi searching of various image files(jpgs, bmps, etc) mounted on USB drive. He has asked me to post our conversations so that it can help others asking the same question. I fully agreed with him. Below are some of the details in our email to one another.

I wrote that in your code

#! /bin/bash
fbi -noverbose -a -t $INTERVAL -u `find $PHOTODIR - iname "*.jpg"`

It seem able to load the images from the various subfolders be it bmps or jpgs., but only what is stated on the 4th line .

For example if I wrote
fbi -noverbose -a -t $INTERVAL -u 'find $PHOTODIR -iname "*.jpg"` only jpgs will load fine be it in whatever subfolders it is stored.

If I changed it to
fbi -noverbose -a -t $INTERVAL -u `find $PHOTODIR -iname "*.bmp"` only bmps will load fine be it in whatever folders it is stored.

What I want is that fbi will load whatever images files - jpgs, bmps etc - in whatever subfolders - /media/usb0/JPG, /media/usb0/BMP - on the USB drive which I have it automatically mounted on boot as /media/usb0.

He replied that

yes, nothing wrong or unexpected here: this is exactly how the find
command works. "-iname" means "all and only the files with a filename
of this kind. To do what you need, the first way that comes to my mind
is this:

find $PHOTODIR -type f | egrep -i '(jpg|bmp|png)$' (Some typo errors here - please refer to my actual code below)

which means:

a) find all **files** in PHOTODIR and all its subfolders, regardless of
name, type etc

b) then discard from the resulting list all lines BUT those that END
in jpg OR bmp OR png...

With his help and clear explanation, I was able to achieve what I wanted.

Below is my actual code:

#! /bin/sh


cd /media/usb0

/usr/bin/fbi - noverbose -a -t $INTERVAL -u `find -type f | egrep -i "(jpg|nmp|png|gif}$"`

Now I just need to plug in any USB drive with any type of image files stored in whatever folders and have fbi displayed it.




Though not as cool as apps that can take over the whole screen (like PowerPoint or its various clones in Windows), browser-based slide shows will work on any machine that has a web browser. If you use one of the JavaScript apps available online, all you need is a browser with JavaScript enabled, and a folder containing the image files, an html template page, and the script. If you host the show either locally or from the cloud with a server-side page preprocessor like PHP, then you can obtain all sorts of customized control over your presentation if you know how to write PHP scripts. My simplest script is only about 5 lines and just modifies the page's CSS using an if statement that responds to a couple of buttons. There are probably a lot more ways to do this if you are tech-savvy and don't have access to the big-name presentation apps or don't like the way they work.


l_e_cox you are right. Personally, the reason why I developed and prefer this other method is that I often end up doing talks a) in places where I have no guarantee that there will be a decent browser available and b) much more important, they demand from all speakers to deliver a .odp/.ppt/pdf version either before or right after the talk.

Editor's Picks