28 August 2018

Raspberry Pi Photo Slideshow

I decided I wanted to use a Raspberry Pi to run a slideshow device, similar to the old scrolling photo screens. I needed something with an HDMI port that would scroll through my chosen photos with no user interaction. Raspberry Pi was a good choice for me as I already had two, they are low power and cheap. Plus if I lost one it would be considerably less painful than losing a laptop.

So first thing first I needed to sort the hardware out. I already had a Raspberry Pi 2 and a Raspberry Pi 1 so I wanted to use them. I wasn’t initially sure how the 1 would perform, but eager to see. The only other difference should be the SD card in the 1 and the micro SD card in the 2. Thankfully this made no difference to the process at all.

Next thing was the operating system. I downloaded Raspbian stretch with desktop and installed it on the SD card. Then of course fired it up and ran through the setup process. I deliberately didn’t set a password so the raspberry could log straight in. All of this was pretty straightforward.

Next I added the photos. The quickest way to do this was shut the raspberry down and plug the SD card into my laptop and copy the images onto the SD card. I put the images in /home/pi/Pictures/

Next I needed the slideshow part. For this I found a nice little tutorial:

This boils down to the following commands:

sudo apt-get install feh

Feh is a simple image viewer. Next we need a screensaver application that will show the images and scroll through them.

sudo apt-get install xscreensaver

This needs a little configuration. So goto start -> Preferences -> Screen Saver
Set the blank out time to 720. As the above article mentions this is the maximum time that you can force the screensaver can run for.

Test it out by running this command:

feh -Y -x -q -D 5 -B black -F -Z -z -r /home/pi/Pictures/

To exit press q.

Now we need to setup the pi so it starts the slideshow when it boots up, meaning all we have to do is power it up and it’s away. This bit got a bit more tricky. First we create an executable file with the feh command in so it can be run. I created this file at /home/pi/ and called it superscript. I gave it all permissions:

    Sudo chmod 777 superscript

Try running this a few times and make sure it works, it’s easier to diagnose problems now than it is later.

Lastly we need to run out superscript file on startup. To do this goto this folder:

    /etc/xdg/autostart/

And create a file called imageStartup.desktop

Add the following contents:

[Desktop Entry]
Type=Application
Name=imageStartup
Comment=All your base are belong to me
NoDisplay=false
Exec=/home/pi/superscript
NotShownIn=GNOME;KDE;XFCE;

Give this permissions as well and you are all set! On restart your images should loop.

Enjoy.

No comments: