# Instagram Photo Frame

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/131/740/medium800thumb/hacks_frame2.jpg?1723054280)

You can build a DIY digital photo frame to display pictures from any public Instagram account. Using a simple tool to grab images and a slideshow viewer, you can enjoy IG pics from the comfort of your living room!

A Raspberry Pi single board computer with display and a WiFi connection are all you need. Plus, you can set it and forget it -- a perfect gift for a family member or friend!

![](https://cdn-learn.adafruit.com/assets/assets/000/131/861/medium800/hacks_frm2.jpg?1723667942)

### Raspberry Pi 4 Model B - 2 GB RAM

[Raspberry Pi 4 Model B - 2 GB RAM](https://www.adafruit.com/product/4292)
The Raspberry Pi 4 Model B is the newest Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 4...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4292)
[Related Guides to the Product](https://learn.adafruit.com/products/4292/guides)
![Angled shot of Raspberry Pi 4](https://cdn-shop.adafruit.com/640x480/4292-03.jpg)

### Pi Foundation Display - 7" Touchscreen Display for Raspberry Pi

[Pi Foundation Display - 7" Touchscreen Display for Raspberry Pi](https://www.adafruit.com/product/2718)
The **7” Touchscreen Display for Raspberry Pi** gives users the ability to create all-in-one, integrated projects such as tablets, infotainment systems and embedded projects!

The 800x480 display connects via an adapter board which handles power and signal conversion....

In Stock
[Buy Now](https://www.adafruit.com/product/2718)
[Related Guides to the Product](https://learn.adafruit.com/products/2718/guides)
![Top down view of a finger touching the screen of a Pi Foundation Display - 7" Touchscreen Display for Raspberry Pi. ](https://cdn-shop.adafruit.com/640x480/2718-07.jpg)

### SmartiPi Touch Pro for Raspberry Pi and Official 7" Display

[SmartiPi Touch Pro for Raspberry Pi and Official 7" Display](https://www.adafruit.com/product/4951)
Here is an updated, excellently designed stand that provides a sleek and sturdy look for the&nbsp;[7" Touchscreen Display](https://www.adafruit.com/product/2718) and[Raspberry Pi](https://www.adafruit.com/categories/288). Say hello to the...

In Stock
[Buy Now](https://www.adafruit.com/product/4951)
[Related Guides to the Product](https://learn.adafruit.com/products/4951/guides)
![Angled shot of assembled SmartPi Touch Pro. The touchscreen displays a wallpaper of a European cityscape at sunrise.](https://cdn-shop.adafruit.com/640x480/4951-03.jpg)

### Official Raspberry Pi 5 Desktop Kit - Pi 5 Sold Separately

[Official Raspberry Pi 5 Desktop Kit - Pi 5 Sold Separately](https://www.adafruit.com/product/5824)
The Raspberry Pi 5&nbsp;is the newest Raspberry Pi computer, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 5 better than the 4? How about a&nbsp;_faster_ processor, USB 3.0 ports, and an updated Gigabit Ethernet chip with PoE...

In Stock
[Buy Now](https://www.adafruit.com/product/5824)
[Related Guides to the Product](https://learn.adafruit.com/products/5824/guides)
![Overhead shot of electronics kit.](https://cdn-shop.adafruit.com/640x480/5824-00.jpg)

# Instagram Photo Frame

## Raspberry Pi SD Card Setup

## Raspberry Pi Quick Start

If you're setting up your Raspberry Pi for the first time, head to the [official Raspberry Pi Getting Started guide](https://www.raspberrypi.com/documentation/computers/getting-started.html). Here are the steps to follow:

- [Download the Raspberry Pi Imager app](https://www.raspberrypi.com/software/) for your operating system on your main computer -- you'll use it to image a microSD card
- Pick your Raspberry Pi model (in my case Raspberry Pi 4)
- Choose the operating system (Raspberry Pi Desktop OS (64-bit) port of Debian Bookworm
- Pick your SD card
- Follow the prompts to flash the card

![hacks_Screenshot_2024-08-07_at_1.32.36_PM.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/743/medium640/hacks_Screenshot_2024-08-07_at_1.32.36_PM.jpg?1723062934)

- Once the SD card is flashed, eject it from you computer
- Insert the SD card in the Raspberry Pi's microSD card slot

# Instagram Photo Frame

## Assemble the Photo Frame

You can use nearly any combination of Raspberry Pi SBC and display for this, but a very nice, compact, photo frame-like option is the Pi Foundation 7" touchscreen display plus the Smarti Pi touch pro case/stand.

If you're using the Smarti Pi case, here are the [official assembly instructions](https://cdn.shopify.com/s/files/1/0793/8029/files/touch_pro_assembly_instructions_0406.pdf?v=1712402193).

Danger: Be sure to insert the microSD card you prepared with the operating system before assembling the case.

![](https://cdn-learn.adafruit.com/assets/assets/000/131/741/medium800/hacks_igframe-0638.jpg?1723060137)

![](https://cdn-learn.adafruit.com/assets/assets/000/131/742/medium800/hacks_igframe-0639.jpg?1723060165)

Once, assembled, plug in a mouse and keyboard to get things set up initially. You can later unplug them for photo frame use.

![](https://cdn-learn.adafruit.com/assets/assets/000/131/818/medium800/hacks_keeb.jpg?1723574314)

# Instagram Photo Frame

## Software Setup

Power up the Rasbperry Pi by plugging in the USB power adapter, then follow the on-screen prompts set up your WiFi network, keyboard layout, and localization.

## Optional Frame Orientation

You may want to orient your frame as a portrait (tall) instead of a landscape (wide) display. To do so, follow these steps:

To rotate the orientation of the data sent to the TV, you'll add a single line to the Pi Zero's configuration text file. Type this in a terminal to edit the file:

`sudo nano /boot/config.txt`

and then press **return.**

You can add the new line at the very bottom of the file. Type this in on a new line:

`#rotate the display: 0=normal, 1=right vertical, 2=upside down, 3=left vertical`

That line is a comment, which won't be read by the machine, just us humans. Comment lines are preceded by the # symbol.

On the next line, type this:

`display_rotate=1`

Now, you can save the file ( **ctrl-x, Y** es,&nbsp;**return)&nbsp;**and then **&nbsp;restart&nbsp;** the Pi Zero by typing:

`sudo reboot`

Get ready to turn your neck sideways or rotate your monitor to continue! If you ever need to go back to regular orientation, change the config.txt file's display\_rotate value to 0.

![hacks_projects_P9130122_2k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/131/852/medium640/hacks_projects_P9130122_2k.jpg?1723662541)

## Install Instaloader

Instaloader is the application you'll use to grab your pictures from an Instagram account. Head [here](https://instaloader.github.io/installation.html) to follow the instructions to install it on your Raspberry Pi from the terminal. I used the following command:

- `pip3 install --break-system-packages instaloader`

This should return `Successfully installed instaloader-4.12.1 or later`

## Directory Prep

You can keep things tidy by creating a directory for the photo frame scripts and pictures. In the terminal type:

`mkdir /home/pi/igframe`

This will create a folder named **igframe.**

Navigate to the directory by typing:

`cd /home/pi/igframe`

## Instaloader Image Download

From inside the igframe directory you can test out Instaloader. By default, Instaloader will grab images, videos, captions, metadata, and more, but we just want the still image files. Enter:

`instaloader profile adafruit --no-videos --no-profile-pic --no-metadata-json -no-captions`

This will automatically create a new directory inside the current directory named for the profile - `adafruit` - and then start downloading the IG images to the directory. You'll see feedback as the images download -- IG currently will limit this to twelve posts unless you are logged into your account. In case it seems to be downloading lots and lots of images without stopping you can hit **ctrl-c** at any time to stop it.

Note, you can substitute another IG account name if you like!

Check out the contents of the /home/pi/igframe/adafruit directory, you should see images from the latest twelve posts.

## Install and Configure feh

**Feh** &nbsp;is a very nice command line image viewer, that happens to be perfect for running a slide show with specific parameters.&nbsp;

&nbsp;Let's install&nbsp; **feh**! Type this into the Terminal window, and then press&nbsp; **return** :

`sudo apt-get install feh`

This will download the necessary files and then install the application. When prompted, type **Y&nbsp;** and press&nbsp; **return** &nbsp;to continue.

`DISPLAY=:0.0 XAUTHORITY=/home/pi/.Xauthority /usr/bin/feh --quiet --preload --randomize --full-screen --hide-pointer --slideshow-delay 5.0 /home/pi/igframe/adafruit &`

## Script It

Instead of retyping that command every time you want to run a slideshow, you can create a special type of text file, known as a shell script, to store the command (or many commands). This shell script can then be invoked any time you want to run the commands contained within.

Create a new shell script with this command:

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

Once again, this will launch the **nano&nbsp;** text editor. Copy and paste the code below into this into the file:

```auto
#!/bin/bash

# Define variables
PROFILE="adafruit"  # you can type in any public IG account name here
PAUSE=20.0  # how long you want to wait between images

IMAGE_DIR="/home/pi/igframe/$PROFILE/"
FEH_CMD="/usr/bin/feh --quiet --preload --randomize  --reload 60 --hide-pointer --slideshow-delay $PAUSE $IMAGE_DIR"
DISPLAY_ENV=":0.0"
XAUTHORITY_ENV="/home/pi/.Xauthority"

# Export the environment variables
export DISPLAY=$DISPLAY_ENV
export XAUTHORITY=$XAUTHORITY_ENV

# Start feh in the background and save its PID
$FEH_CMD &amp;
FEH_PID=$!

while true; do
  # Run instaloader and check for errors
  instaloader profile $PROFILE --no-videos --no-video-thumbnails --no-captions --no-profile-pic --no-metadata-json
  if [ $? -ne 0 ]; then
    echo "No new images downloaded."
  else
    echo "Images downloaded successfully."
  fi
  
  # Sleep before repeating (3600 seconds in an hour)
  sleep 7200
done
```

Close and save the shell script by pressing&nbsp; **ctrl-x&nbsp;** and then&nbsp; **Y&nbsp;** and&nbsp; **return.**

Now, run the shell script -- which will in turn run all of the contents of the file&nbsp;-- by typing this:

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

That just ran your slideshow with a much shorter command. Much easier!

## Permissions

Let's have a look at the current file permissions. In your Terminal, type this in to the list directory contents with verbose info:

`ls -l /home/pi/igframe`

&nbsp;

That list of letters on the left side in front of each file shows you what type of permissions exist for the file.

Possible permissions are read, write, and execute for three types of accounts: owner, group, and user.&nbsp;[Here's](https://glug.nith.ac.in/blog/file-permissions-in-linux-chown-and-chmod-explained/)&nbsp;a very good primer on the subject.

For the slideshow script we see:&nbsp;

`-rw-r--r--`

which means the file can be read and written by the owner ("root"), and only read (not executed or written) by groups and by users. This means the system (user "pi") doesn't have execution permission. So, we want to adjust that so the system can actually run the script without user intervention.

This simplest way to adjust this in our case is to grant execution&nbsp;permissions to all users. The&nbsp; **chmod** &nbsp;command is used to do so. Type this in your Terminal:

`sudo chmod 755 /home/pi/igframe/start-picture-frame.sh`

![](https://cdn-learn.adafruit.com/assets/assets/000/131/860/medium800/hacks_frm2.jpg?1723667923)

## Autostart the Script

You may want to set up the Pi to automatically run your slideshow script on startup. This also means that if there is a loss of power, the system will not spend a long time stuck on a Linux screen!

To set the script to automatically run on startup we'll add a line to the desktop environment configuration script that automatically runs our picture frame shell script upon launch.

Open the autostart file for editing by typing:

`sudo nano ~/.config/lxsession/LXDE-pi/autostart`

Add a new line at the bottom and enter this text:

`@./igframe/start-picture-frame.sh`

As is by now the familiar routine, save and exit the file with&nbsp; **ctrl-x, Y, return.**

Once again, you'll need to restart the Pi to see the effects of your changes, so type:&nbsp;

`sudo reboot`

This time, once the Pi reboots, it will launch the desktop, and then start the slideshow! How automagical!


## Featured Products

### Raspberry Pi 4 Model B - 2 GB RAM

[Raspberry Pi 4 Model B - 2 GB RAM](https://www.adafruit.com/product/4292)
The Raspberry Pi 4 Model B is the newest Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 4...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4292)
[Related Guides to the Product](https://learn.adafruit.com/products/4292/guides)
### Pi Foundation Display - 7" Touchscreen Display for Raspberry Pi

[Pi Foundation Display - 7" Touchscreen Display for Raspberry Pi](https://www.adafruit.com/product/2718)
The **7” Touchscreen Display for Raspberry Pi** gives users the ability to create all-in-one, integrated projects such as tablets, infotainment systems and embedded projects!

The 800x480 display connects via an adapter board which handles power and signal conversion....

In Stock
[Buy Now](https://www.adafruit.com/product/2718)
[Related Guides to the Product](https://learn.adafruit.com/products/2718/guides)
### SmartiPi Touch Pro for Raspberry Pi and Official 7" Display

[SmartiPi Touch Pro for Raspberry Pi and Official 7" Display](https://www.adafruit.com/product/4951)
Here is an updated, excellently designed stand that provides a sleek and sturdy look for the&nbsp;[7" Touchscreen Display](https://www.adafruit.com/product/2718) and[Raspberry Pi](https://www.adafruit.com/categories/288). Say hello to the...

In Stock
[Buy Now](https://www.adafruit.com/product/4951)
[Related Guides to the Product](https://learn.adafruit.com/products/4951/guides)
### Official Raspberry Pi 5 Desktop Kit - Pi 5 Sold Separately

[Official Raspberry Pi 5 Desktop Kit - Pi 5 Sold Separately](https://www.adafruit.com/product/5824)
The Raspberry Pi 5&nbsp;is the newest Raspberry Pi computer, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 5 better than the 4? How about a&nbsp;_faster_ processor, USB 3.0 ports, and an updated Gigabit Ethernet chip with PoE...

In Stock
[Buy Now](https://www.adafruit.com/product/5824)
[Related Guides to the Product](https://learn.adafruit.com/products/5824/guides)

## Related Guides

- [Raspberry Pi Care and Troubleshooting](https://learn.adafruit.com/raspberry-pi-care-and-troubleshooting.md)
- [3D Printing on Diffraction Grating Sheets](https://learn.adafruit.com/3d-printing-on-diffraction-grating-sheets.md)
- [Theme Park Wait Time Display](https://learn.adafruit.com/park-wait-time.md)
- [Automation with Crickit and Capsela](https://learn.adafruit.com/automation-with-crickit-and-capsela.md)
- [Adafruit Pixel Trinkey](https://learn.adafruit.com/adafruit-pixel-trinkey.md)
- [Raspberry Pi Video Looper 2](https://learn.adafruit.com/raspberry-pi-video-looper-2.md)
- [Pico Four Keypad](https://learn.adafruit.com/pico-four-key-macropad.md)
- [Monochrome OLED Breakouts](https://learn.adafruit.com/monochrome-oled-breakouts.md)
- [Compiling a cross-compiler on Windows](https://learn.adafruit.com/compiling-a-cross-compiler-on-windows.md)
- [MPR121 Capacitive Touch Sensor on Raspberry Pi & BeagleBone Black](https://learn.adafruit.com/mpr121-capacitive-touch-sensor-on-raspberry-pi-and-beaglebone-black.md)
- [Ambient Video Lighting with HyperHDR](https://learn.adafruit.com/ambient-video-lighting-with-hyperhdr.md)
- [Adafruit PiCowbell DVI Output](https://learn.adafruit.com/adafruit-picowbell-dvi-output.md)
- [USB to Eurorack Power Supply](https://learn.adafruit.com/usb-to-eurorack-power-supply.md)
- [Appler - The Apple II Emulator for MS-DOS](https://learn.adafruit.com/appler-apple-ii-emulator-for-dos.md)
- [Running TensorFlow Lite Object Recognition on the Raspberry Pi 4 or Pi 5](https://learn.adafruit.com/running-tensorflow-lite-on-the-raspberry-pi-4.md)
- [LED Drone Matrix](https://learn.adafruit.com/led-matrix-drone.md)
