A Simple Raspberry Pi Photo Frame

The Raspberry Pi photo frame is a perfect setup for anyone who wants to display photos of their loved ones, memories or anything else might want to display.

Raspberry Pi Photo Frame

This photo frame is a pretty straightforward project and shouldn’t take you too long to set up. You will need the full version of Raspbian installed as we make use of the graphical user interface (GUI).

I pretty much only cover the software side of things in this tutorial there are some pretty cool frame designs out there if you want to extend this further.

The digital photo frame we make is very basic and can be kept completely offline. Connecting to services such as Google Drive and Flickr will require a lot more work.

Equipment

The equipment that you will need for this digital photo frame is listed below.

Recommended

Optional

Video

If you want to see a video on how to do this tutorial, then be sure to check out the one below.

I go through everything you need to know about getting this project working.

Adblock blocking the video? Subscribe to premium for no-ads.

Hardware

For this project, I am just using the official Raspberry Pi touchscreen that I purchased earlier this year. However, you can use pretty much any screen that you can get your hands on. Just make sure you can hook it up to the Pi either over the DSI port, HDMI port or using a custom HAT.

If you’re looking for some 3D printable frames for either the official touch screen or just a spare screen you have, then Thingiverse has some pretty cool designs. You can find them over at Thingiverse.

Setting Up the Raspberry Pi Photo Frame Software

To get this all setup correctly we are going to need to do a bit of setup on the software side of things.

Firstly, we want to prevent the screen from going blank. It is a power saving setting on the Pi.

1. To turn off screen blanking, open up the lightdm.conf file in the nano text editor.

sudo nano /etc/lightdm/lightdm.conf

2. Now in here add the following line anywhere beneath the [SeatsDefaults] line.

xserver-command=X -s 0 –dpms
raspberry pi black screen

3. Save & exit by pressing CTRL + X and then Y.

4. Now reboot the Pi, and the screen should no longer switch off after 10 minutes of inactivity. To reboot simply run the following:

sudo reboot

If you want to be able to drag and drop your images onto the Pi, you may want to look at setting up a network attached storage. Will allow you to set up a folder that is available on your local network. If you’re in doing such a thing, then my guide on a Raspberry Pi Samba server will take you through all the necessary steps.

I also highly recommend that you setup SSH so you will have remote access when the slideshow is in action. There is no easy way to exit the slideshow unless you turn the device on and off and don’t have it automatically starting.

To set up our slideshow, we’re going to use the feh package.  Feh is image viewer and cataloguer. It is a fast image viewer that doesn’t get bogged down with huge GUI dependencies. I chose this as it was the most lightweight package that worked without any huge complications.

1. To install the package, use the following line:

sudo apt install feh

2. Now to test that it works enter the following line. Replace /media/NASHDD1/test with the directory that contains all your image.

DISPLAY=:0.0 XAUTHORITY=/home/pi/.Xauthority /usr/bin/feh --quiet --preload --randomize --full-screen --reload 60 -Y --slideshow-delay 15.0 /media/NASHDD1/test

3. Now we can use short tags to make this command a lot shorter. You can read more about all the flags you can use over at the feh manual page.

DISPLAY=:0.0 XAUTHORITY=/home/pi/.Xauthority /usr/bin/feh -q -p -Z -F -R  60 -Y -D 15.0 /media/NASHDD1/test

4. Now as you will notice this locks up the command line bar. To fix this, add the & after the command and the script/process will launch in the background.

5. So now let’s store this in a simple script file. This way you can add or change it later. To make the file enter the following command.

sudo nano /home/pi/start-picture-frame.sh

6. In here, enter the following lines.

#!/bin/bash
DISPLAY=:0.0 XAUTHORITY=/home/pi/.Xauthority /usr/bin/feh -q -p -Z -F -R  60 -Y -D 15.0 /media/NASHDD1/test

7. Now that’s done you can test it by running the following command.

bash /home/pi/start-picture-frame.sh

8. Finally, let’s have it start at boot. Now it is important that you have SSH enabled so you can access the Pi remotely as you will lose access to the GUI/Screen. So make sure you have done this before setting it to launch at boot up.

9. To do this open up the rc.local file by entering the following command.

sudo nano /etc/rc.local

10. Add the following before the exit 0 line in this folder.

sleep 10
bash /home/pi/start-picture-frame.sh &

11. If you ever need to kill the process as you may want to be able to access the desktop, simply enter the following line.

sudo pkill feh

Conclusion

You should now have your very own slideshow of pictures going. If you end up with any troubles, then double check all the steps and look for any errors. If you’re still having trouble, then be sure to seek help in the comments section below.

I hope you have been able to get your Raspberry Pi photo frame working correctly. If you have any trouble or have an extension that you would like to share, then be sure to leave a comment. As always if you like my stuff be sure to follow Pi My Life Up on any major social network.

63 Comments

  1. Avatar for David
    David on

    This was an excellent tutorial. I used it to help make a wall-hanging picture frame.
    One minor problem: the text in step 10 is incomplete. The file path is wrong and sudo is missing.

    1. Avatar for Gus
      Gus on
      Editor

      Thanks David! I will fix that up.

    2. Avatar for Sierra B
      Sierra B on

      I just finished this project, and it’s working good so far!

      I also had to figure out to add sudo and pi to Step 10. Might be good to edit that in the post now.

      Thank you so much for this tutorial! My cute cats electronic photo frame is a success!!

      Do you think it’s dangerous to turn off with a switch on the power cord, and not by shutting down in PuTTY?

  2. Avatar for anonymous
    anonymous on

    hey.i am using raspberry pi for the first time.can you please help me by telling how to actually start this coding?i want to make a photoframe using raspberry pi 3.but unable to do so coz firstly i am not able to connect my pi to wifi. Also,i dont understand that where to do all this coding?do we have a separate software for this or it should be written on the terminal?and is it this pi coding to do anything with my laptop?i mean do i need my laptop for this?or just have to do all the coding on pi only??
    for you it may be a useless question but i need to know coz i havent used all this before.
    thanx.

    1. Avatar for djb
      djb on

      It’s ambitious to jump into a bigger project right off the bat. Better to take a few steps at a time. Setup the raspberry pi. Install the OS. In the process, you’ll learn a little about the editor and things will start to make much more sense. It is also hard to provide help when you ask for it as anonymous.

  3. Avatar for Wes
    Wes on

    Does this work with the Raspberry Pi Zero? Thank you!

    1. Avatar for Jacob AShenberner
      Jacob AShenberner on

      I’ve got it working on my pi zero. I deleted the –preload command to speed up the initial slideshow loading.

  4. Avatar for Dan King
    Dan King on

    Great post! You may want to check out DAKboard for the software side of things. It integrates with Flickr, Dropbox, Instagram, 500px and more. Run it full screen in any web browser. DAKboard adds calendars, news and weather to the mix as well!

  5. Avatar for JSI
    JSI on

    Great post! I will be using this for a digital sign in the office. My users will create their images in photoshop and use filezilla to copy it into the /home/pi/Pictures folder. Like others I had problems getting it to auto start. Debian Jessie changed when rc.local runs to be earlier in the process. That messes up these instructions, so to the rc.local file I added:

    #debian jessie changed when rc.local runs this command makes it wait until the system is ready
    sleep 10

    #command to start the picture frame
    sudo /bin/bash /home/pi/start-picture-frame.sh &
    #end command

    I know adding sleep 10 is hackish and there is probably a better way, but it works.

  6. Avatar for JP Montoya
    JP Montoya on

    Hey,
    Does anyone know if it is possible to also play animated GIFs -among static pictures- in this slideshow?
    Any ideas on how to accomplish that?

    GREAT POST!

  7. Avatar for PiNoob
    PiNoob on

    When I add the line to stop the display from turning off, my Light Display Manager fails to start and the GUI does not load. I also get the feh error: can’t open X display.
    Need to stop the display from turning off but these steps do not seem to work. I am using the most current NOOBS installation of Raspbian (may 2016)

    1. Avatar for Jake
      Jake on

      Only way I’ve been able to fix this issue is install xscreensaver. To install you need “sudo apt-get install xscreensaver” . In the gui you will now have the “screensaver” option under preferences. Here you can disable the blank screen.

  8. Avatar for netmak
    netmak on

    thnx for the great tutorial..!

    the only thing was that i had to put

    sudo bash /path/to/script into the rc.local

  9. Avatar for Mark
    Mark on

    Awesome article but I guess i’m missing something. Does the PI have terminal access out of the box or are you loading some version of linux like raspbian or chromium before doing this DIY?

  10. Avatar for antonio
    antonio on

    hi i have a problem,the sh file works good but itsn execute when restarting the system :S

    1. Avatar for doug
      doug on

      I discovered I had to change permissions on rc.local. chmod 755 rc.local. The 755 is probably overkill but I don’t really care since my Pi won’t be on a network when running feh.

  11. Avatar for Gavin
    Gavin on

    Great tutorial, is there a simple way to play a mp3 on a loop in the background which is embedded on the HDMI?

  12. Avatar for Eli
    Eli on

    This is our first project (aside from getting the pi going.) We are stuck on step 2. When I paste our own directory into the command line I get the error message. feh: no loadable images specified. The images are jpgs. I have moved the folder from a USB stick to the desktop and have put just a few pics into the folder which I think should be specified by the path: /home/pi/Desktop/Sample picture frame
    The whole command looks like this: DISPLAY=:0.0 XAUTHORITY=/home/pi/.Xauthority /usr/bin/feh --quiet --preload --randomize --full-screen --reload 60 -Y --slideshow-delay 15.0 /home/pi/Desktop/Sample picture frame

    I imagine we are missing something really basic.

    1. Avatar for Eli
      Eli on

      I renamed the folder of media to Samplepictureframe and edited the command line appropriately to good effect. I assume that any space in the command line has some significance I had not appreciated. Is that right?

    2. Avatar for SoftBear
      SoftBear on

      Yes, that is right. Unless you quote a file path, it cannot contain any reserved characters (i.e. spaces, semi-colons, etc.)

  13. Avatar for Dalton
    Dalton on

    I have double checked all the steps. I can run bash /home/pi/start-picture-frame.sh without any problems. However, I can’t get it to autorun at startup. followed all the steps and double checked it. Any help would be greatly appreciated.

    1. Avatar for David
      David on

      Like you, I couldn’t run the bash script out of rc.local the way the instructions were written – probably a difference in Raspbian since the original instructions were written. I put the following line into my rc.local and the system autoruns fine:

      su – pi -c ‘/bin/bash /home/pi/start-picture-frame.sh &’

    2. Avatar for Rob Lee
      Rob Lee on

      I noticed that the instructions are missing the /pi/ folder in the Bash line:

      bash /home/start-picture-frame.sh &

      should actually be

      bash /home/pi/start-picture-frame.sh &

      Changing that got the slideshow to autorun at startup.

    3. Avatar for Rob
      Rob on

      So did I, however, despite adding the /pi to the path it still doesn’t autostart, neither does the previous fix of preceding the line with su. In addition I’ve changed the permissions to make it executable as well and that also hasn’t worked.

      Any suggestions?

    4. Avatar for Eric
      Eric on

      this has not worked for me either. I can get the start-picture-frame.sh to run with the command

      bash /home/pi/start-picture-frame.sh

      but I cannot get it to auto run after reboot. I have the following:

      sleep 10
      su - pi -c '/bin/bash /home/pi/start-picture-frame.sh &'

      but it does not work.

      any help is greatly appreciated.

    5. Avatar for Ralph
      Ralph on

      For me it did also not work at all. I had to edit /etc/profile and add at the end of that file 'bash /home/pi/script2call.sh &

      Then it worked (finally ;-).

      Regards, Ralph

    6. Avatar for Eric W.
      Eric W. on

      @Ralph,

      I tried what you said and various other iterations of it and still its not working.

      when i attempt to log in via ssh (putty) i see an error:

      -bash: bash /home/pi/start-picture-frame.sh &: No such file or directory

  14. Avatar for Jonas
    Jonas on

    I cant make the start-picture-frame.sh run at start-up i get the error :feh ERROR: you have no HOME, cannot read themes. What am I doing wrong ? : )

    1. Avatar for Rooki
      Rooki on

      I have a same issue. What can i do?

  15. Avatar for George
    George on

    how can i auto mount my nas i already have at home in startup so i can display photos from it

    1. Avatar for Frank M. Ramaekers Jr.
      Frank M. Ramaekers Jr. on

      Simply add it to your /etc/fstab

  16. Avatar for Awei
    Awei on

    Hello,

    I put around 900 photos in my usb drive, and the total size is around 500 mb. However, it seems like it cannot load such huge amount of pictures. When I put only few photos, it loads pretty fast tho.

    Do you have any suggestions on fixing that?

    Thanks,

    1. Avatar for Gus
      Gus on
      Editor

      Hi Awei,

      You could try removing the -p (–preload) tag, this will stop it from scanning through all the images at start up.

      I haven’t tested this but when I do get the time I will test it and try work out how to best deal with huge amounts of images.

  17. Avatar for Eric
    Eric on

    Hi,

    It seems that pictures can keep the original aspect ratio. How to keep the photo’s aspect ratio so that it won’t get stretched or squeezed.

    Thanks,
    Eric

    1. Avatar for Eric
      Eric on

      Oops… sorry, it’s not stretched or squeezed. it’s my HDMI cable’s problem. It’s all good now.

      Thanks,

  18. Avatar for Johan Huang
    Johan Huang on

    Hi, i am using Jessie. Should i run this ‘feh’ in condition that Xwindow already running?

    I setup my pi to boot up directly to cli. This ‘feh’ can’t run.

  19. Avatar for Wayne
    Wayne on

    trying to set this up, i keep getting

    ‘feh ERROR:Can’t open X display. It *is* running, yeh?’

    This is with the official display or just a HDMI monitor, both work just fine editing command line and statrx. All code is direct copy/paste from above with exception of media/usb.

    Any help appreciated.

    1. Avatar for Gus
      Gus on
      Editor

      Hi Wayne,

      This error seems to only occur when the Raspbian GUI is not up and running. You can start it using the following command on the pi itself. sudo startx

      If you have done this can you please let me know the model of your Raspberry Pi and the OS version (Jessie or Wheezy). I’ll try and replicate the issue here.

    2. Avatar for David
      David on

      Same issue here. Pulled out an older Pi (A+) and installed fresh Jessie (post 3/18 with a freshe update/upgrade). I launch into the GUI. Can’t make it run from terminal or rc.local. I get the ‘feh ERROR:Can’t open X display. It *is* running, yeh?

      I have it working successfully on an Orange Pi running Ubuntu Mate (took a few changes about files and locations) so the process is sound. Any luck with Wayne’s issue, Gus? Thank you.

    3. Avatar for David
      David on

      Solved the problem. For want of a nail, the kingdom was lost.

      After 8 frustrating hours, I decided to blast away the SD and do a fresh start. Built up a new Jessie with the usual long update/upgrades. Added some utilities and started up the picture frame project. Got to the same place and had the same freakin’ problem. So the only possibilities were the board or the operator. I assumes operator error and went through every step, script, character etc. Finally was able to successfully run the test from the terminal prompt. Turns out I was missing the “:” after “DISPLAY=”
      So for want of a colon, the script was lost.

      Woohoo. Updated the bash script and rebooted. Nothing. Did a little digging into rc.local. Calling bash without a bit more power didn’t cut it so I made the bash call:

      su – pi -c ‘/bin/bash /home/pi/start-picture-frame.sh &’

      Et viola!

      So now it’s working on an Orange Pi and a Raspberry.

      My project calls for the system to boot up totally headless with nothing but a power connection and an hdmi connect to a projector. It is for a one man show and displays a single, never changing image on a screen (two screens that are two far apart to use a single source withing converting HDMI to Cat5, running the distance and converting back to HDMI). Because there is no user input, it had to have auto login enabled. Raspi config handles that on the Raspberry but must be manually put into

      /usr/share/lightdm/lightdm.conf.d/60-lightdm-gtk-greeter.conf
      This is also where the xserver=… must go

      As talent, my guy can’t login and run it – he just runs up on stage to do his thing after hitting the power switch on the strip that runs the Pi and Projector. And that’s what they do now. Thanks for a great instructable.

      If anyone needs details on the differences in doing this on the OPi or with Ubuntu Mate, leave me a note and I’ll add what I learned.

  20. Avatar for Wayne
    Wayne on

    Thanks! I’ve used your guides a few times now with great success. This is just what i need to ‘keep the Mrs happy’ and to use a Pi for something she can appreciate for once.

Leave a Reply

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