logo
background
 Home and Links
 Your PC and Security
 Server NAS
 Wargames
 Astronomy
 PhotoStory
 DVD making
 Raspberry Pi
 PIC projects
 Other projects
 Next >>
[The software] [Using samba] [Using a 4Gb SDHC card] [Using fbi] [Downloading the scripts] [Auto-running the scripts] [Alternatives to fbi]
Pi PhotoFrame (fbi)

The software

As usual, what you need depends on what you want to do !

Many 'NOOBS' users will go straight for the GUI (startx) .. however instead of 'photo-frame', that means we have a computer with a 'screen saver' to program. For me, the problem of a GUI is it's complexity - my experience with a PC based Photoframe convinced me that there would always be 'something' that prevented the display running 'as it should' (and tracking down the 'something' can be next to impossible)

So I started by running (testing) everything from the command line interface (CLI), after which the commands were 'transferred' to a simple Bash shell script. As usual, of course, nothing was ever as simple as it should be (for one, to allow the Bash shell script to be 'launched' after a power-up sequence, it must be 'executable' (chmod 775 or +x), and second, if you want to keep things 'simple', the script should be in the same folder as the images you want to display).

After looking into various command line display utilities (see at end, below) I eventually discovered that the simplest (fbi) was the only one that could be 'convinced' to do the job

[top]

Using samba (and finding folders)

One 'feature' for *nix systems is that each 'logged in user' has their own 'home' directory (just like in Windows you default to your own desktop).

This is fine when multiple users are doing multiple different things, but a REAL PAIN when you are trying to get the scripts you setup in your 'home' to launch at power-on (when 'home' = system) and then find photos in some other (hopefully 'fixed' folder)
 
The 'secret' is to make ALL new folders fixed 'off the root' (for example "mkdir /photos/" and NOT "mkdir photos/") and place the scripts and photos in them, and not in your 'home# directory

Needless to say, everything is a lot easier (testing, modification, loading photos, backup etc) if the 'root' of your photoframe directory 'structure' is 'visible' from your PC

This means installing 'samba', which allows a Pi directory (and everything in it) to be seen as a 'mapped network drive' on a PC

(+) Installing samba - (the Pi as a Network Share on your PC)


[top]

Using a 4Gb SDHC card

The 'easy' way to 'back up' a Pi is to 'image' the contents of the SDHC card to a file on your PC using Win32 disk Imager - and then 'write' that out to a new card that's 'double the size'

To 'restore' a back-up to the same sized card usually means 'shrinking' the Pi partition sizes and making a new backup - it's possible but a right pain - for details, read the Note below :-

(+) How do I change the Pi System partition size ?

Since I'm going to use a cheap Class 4 8Gb card for the final Photoframe Project, starting with a 4Gb card avoids all that partition size issues

After you copy the 4Gb image to an 8Gb SDHC, boot the 8Gb and run the init_resize.sh script :-
sudo init_resize.sh
(this will 'auto-resize' the 4Gb partitions to the new 8Gb card)

[top]

Using fbi

The 'Frame Buffer Interface' program (fbi) has one major shortcoming = it can't be run as a background task (and can't even be 'launched' from a background running script).

When fbi is launched it 'grabs focus' i.e. runs in the foreground, preventing a script from executing any other instructions, until it has finished displaying all the images you specify.
 
For a photoframe, the obvious approach is to tell fbi to display photos 'for ever', in which case fbi will 'lock up' your command terminal window preventing that 'terminal session' being used for anything else. The other problem is (of course) that fbi only shows the images that were present when it is launched (so you can't update a 'running' slideshow)
 
If, on the other hand, you tell fbi to display images 'one at a time' (so you can update), there will be a very visible 'gap' between images.
 
When fbi is run 'one image at a time', after showing the 'one image' it switches the display back to the CLI terminal window before allowing you to launch it again to show the next image. Worse, fbi appears to have some sort of 'memory leak', since, after showing only a few dozen images 'one at a time' (on Wheezy) it filled up all the RAM and crashed the Pi !
 
Of course you can tell it to 'run for-ever' and then 'kill' fbi (and re-launch it) in order to update the photos - however whilst that may 'fix' the RAM leak, the display still reverts to the 'terminal session' (boot status text), plus, after a 'kill', an on screen 'Oops: terminated' complaint, all of which is very noticeable :-)

In the end I gave up and just designed the system so fbi could be launched last and run in 'loop for ever' mode. This meant 'cheating' fbi in order to 'update' the display

The trick is to let fbi 'loop for ever' showing a 'fixed' sequence of a few photos and then 'swap them out' by 'overwriting' them with new ones. This (the swap out) can be done by using a second script running 'in the background'.
 
It turns out that this only works if you start fbi with AT LEAST 3 photos (with 2, fbi just pre-loads them both into RAM - despite the use of the '-cachemem 0' option - and thus never picks up the new file contents, however with 3 (or more) fbi will actually fetch the 'next' photo from the (SDHC card) each time).
 
The really clever bit is to use 'alias' links, so you can give fbi 3 'fixed' file names that all 'point' to the same 'real' image file.
 
A script running in the background can then update the photoframe image by changing the single 'real' image file that all the 'alias links' are 'pointing at' (instead of having to work out 'which one' to change next)
 
This has the advantage that there are no 'gaps' between images, and, so long as the 'fbi 'cycle time' is short (3 seconds is about the minimum) 'updates' will appear quickly (in 1/3rd the cycle time)

The final trick is to avoid wearing out the SDHC card directory by holding all the 'alias' files in a ram-disk (tmpfs).

[top]

Downloading the scripts

To download the fbi script, right click and 'save link as' go-fbi.sh script (Note 1).
Further details can be found below :-

To download the 'companion' background script, right click and 'save link as' go-photo.sh (Note 1).
Further details can be found here :-

Note 1. If your don't 'Right click' to save the .sh scripts, you will get 'File not found'

[top]

Auto-running the scripts

So the Photoframe starts up automatically at power-on, just add your scripts to rc.local, the list of the 'things to be done' at power-on

cd ..
cd ..
cd etc
sudo nano rc.local
 
If you placed the scripts in the /photos/ folder, add the following directly above the 'exit 0' line :-
bash /photos/go-photo.sh &
bash /photos/go-fbi.sh

Don't forget the '&' after go-photo.sh, so it runs in the background :-)

[top]

Alternatives to fbi

Before I managed to get fbi working the way I wanted, I tried a number of other utilities (with even less success) :-



(-) Other display utilities



Whilst fbi is the solution I adopted, here are some other possibilities you might wish to consider :-

fim (fbi improved)

fim was designed for interactive use with a keyboard user so has the same inability to work in the background problem as fbi. It also lacks the 'noverbose' option (insists on 'writing' a text 'status' line at the bottom of the display), lacks the '-t' option (so won't 'loop' itself) and, when you kill/stop the app. it blanks the top 25% of the display.

With all these extra problems to solve, I eventually decided not to waste any more time with it

For those who wish to persevere:-

fim will obey instructions found in a config file (a .fimrc file in your home directory). The string 'i=0;while(i<10){next;reload;sleep '1';display;}' has the effect of turning fim into 'slideshow' with 1 second pause between images. After launching fim, you can type the same commands at the CLI console (but need to add a leading ':')

'fimgs.sh' is an example of how to drive fim from a shell script. Other examples are found in the "scripts/utilities/" installation directory

Whilst you can 'pipe' a list of images to fim, apparently it waits for user input to move from one of these images to the next, although there is a 'sleep n' (seconds) command, and apparently some way exists to make it behave as a photoframe

feh

This display utility can be run as a background task, however early versions hinsisted on planting a 'cursor' on the display screen !! Whilst you could use a utility called 'unclutter' (sudo apt-get install unclutter) to 'un-draw' the stupid 'cursor' this would only be after some selectable 'idle' time (eg 1s, '/usr/bin/unclutter -idle 1 &amp;')

It also turned out to be impossible to 'fool it' using the 'alias' trick = it scans the image folder when it's started and discovers the real files. So the only way to add a new display image is to stop it (using 'kill `pgrep -f "feh"') and restart it (with 'usr/bin/feh --quiet --preload --recursive --randomize --full-screen --slideshow-delay 5 /path/to/photos/ &amp;') ..


.. and, of course, killing the task reverts the display to the terminal window (along with the 'kill compliant' message) upsetting the sequence of photos. At this point, I couldn't be bothered to investigate it further

The current version is rather more usefull, with a "-Y" option that hides the cursor. Use 'man feh' to get a list of options = typical usage would be "feh -Y -x -q -D 5 -B black -F -Z -z -r /images/" where :-

-Z Auto Zoom
-x Borderless
-F Fullscreen
-Y hide pointer
-B image background
-q quiet no error reporting
-z Randomise
-r Recursive search all folders in folders
-D Slide delay in seconds

To date, I've not checked to see if 'alias' is working

qiv

You can find another photoframe how-to here, this time using 'qiv'.

However it suffers from the same inability to dynamically up-date the show as almost every other 'how-to' I have ever found (if you want to chnage the photos, you have to reboot = see 'Conclusion' at the bottom of the page)

Note that this 'how-to' does include some useful tips on connecting to a share via Wi-Fi and limiting SDHC corruption at power off

pqiv (see here)

This is a X11 (xterm) display utility that was actually designed with an option setting ('-r') that lets you feed it the names of the images you want to display = this should mean you can change the display image to whatever you want, rather than having it 'fixed' when the display utility was started (or playing with 'alias' settings in the background).

echo /home/pi/photos/nextPhoto.jpg > /usr/bin/pqiv -i -f -s -w -r


The problem ??? It has a bug, which, as of 4 Nov 2014 required a manual fix ...

sudo apt-get remove pqiv sudo apt-get install git libgtk2.0-dev git clone https://github.com/phillipberndt/pqiv.git -b 0.12
cd pqiv
./configure
# in 'pqiv.c' using your fav. text editor, search for 'gchar option' and replace with 'gint option'
sudo make all install


Next, it needs xterm - which has to be started at boot - and which you have to 'configure' to accept images from pqiv.

sudo raspi-config # In boot_behavior, enable 'Start desktop on boot?' option

Edit the '/etc/lightdm/lightdm.conf' file

remove the comment # from 'xserver-allow-tcp=false', then, add at end 'xserver-command=X -s 0 -dpms' ...

At this point I gave up, although at least one (German) Pi user has made it work == you can find his instructions here (it helps if you can read German == or use Google to 'translate this page' :-) )


This note last modified: 17th Nov 2017 17:30.

[top]


Next I add a GPIO sensed 'button' to control the Photoframe 'display of the next photo

Next page :- Pi GPIO - (Photoframe pause button)

[top]