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!