Raspberry Pi Photo Frame From Apple Photos

by buzztroll in Circuits > Raspberry Pi

1588 Views, 1 Favorites, 0 Comments

Raspberry Pi Photo Frame From Apple Photos

Today - 1 of 1.jpeg

This project shows how to backup your Apple Photo album to a Raspberry Pi and use that backup as a Photo Frame.


Apple Photos is a great way to organize and mine your photos. The face finding and memory creation features are convenient and effective. However if you want to look at those pictures outside of that application it is difficult.

Apple Photo imports pictures and renames the files to a UUID under the directory originals, like the following:

originals
├── 0
│  ├── 00000BD0-5360-4AD8-BE55-ADDB68A9EFA4.jpeg
│  ├── 00012112-1A80-4B9B-A80E-E84E7D9B7099.jpeg
│  ├── 00013F91-9257-4223-BB1D-436C3488647F.jpeg
│  ├── 00024413-C1A9-478A-8D95-D18F0BFDC2CE.jpeg


Unlike some conventions that lay the data out in directories according to date, making any sense of what picture is where is impossible with just the files system is impossible. Apple Photos has much more information about these files but you are completely stuck using Apple Photos to leverage it.

Another problem with Apple Photos is that it only works well if your photos are stored on a perminently attacked hard drive. Due to background processes that analize your photos, attempting to keep your photos on an external drive causes quite a few problems. This makes sharing an Apple Photo album among many computers very difficult.

Personal pictures are precious and thus you do not want to trust a single machine to hold them all. Backups are essential. And because photo albums get very large very quickly (mine is 700GB and growing) backing them up can be difficult.

In this project I will show how to backup your Apple Photo album to a Raspberry Pi, and once it is backed up how to use that backup as the source for a photo frame.

Supplies

The hardware that you will require is:

  • Raspberry Pi
  • External Hard Drive
  • HDMI Monitor

Any standard Raspberry Pi setup will work. If you wish to do the photoframe portion of the project (and not just the backup) it will need a display. For the hard drive I use a Seagate STGX2000400 but any USB hard drive should work.

For my setup I used a Piper. It was a Christmas gift for my daugher from a couple of years ago but she has since graduated to a chrome book for school. The Piper is ultimately really cool packaging for Raspberry Pi.

The required software is:

  • samba
  • buzzipick
  • rsync

We assume that you have the Raspbian installed and running on your Raspberry Pi. We will walk through the installation of the remaining software below.

Setup the Backup

Screen Shot 2022-10-14 at 9.55.21 AM.png

The first thing to do is configure the Raspberry Pi for backup. Connect your USB drive and start a terminal shell. The Raspberry Pi should automatically mount it under /media/<username>. Run the df program to verify:

bresnaha@piperpi:~ $ df -h
Filesystem     Size Used Avail Use% Mounted on
/dev/root       15G 3.8G  11G 28% /
devtmpfs       333M    0 333M  0% /dev
tmpfs          462M    0 462M  0% /dev/shm
tmpfs          185M 1.2M 184M  1% /run
tmpfs          5.0M 4.0K 5.0M  1% /run/lock
/dev/mmcblk0p1 255M  51M 205M 20% /boot
tmpfs           93M  20K  93M  1% /run/user/1000
/dev/sda1      1.8T 552G 1.2T 32% /media/bresnaha/PIBACKUP

On mine we see that it is at /media/bresnaha/PIBACKUP.

Now install samba:

sudo apt install samba

We will now configure samba to serve your USB drive as a Windows Share. Open the file /etc/samba/smb.conf and add the following to the bottom of it:

[backup]
comment = Pics and other stuff
path = /media/bresnaha/PIBACKUP
Valid users = bresnaha
read only = no
guest ok = yes
writable = yes
privatable = no
browsable = yes


This tells the samba server to allow users to read and write to the USB drive via the share name backup. Note in this configuration there is the user bresnaha. That is the name of one of my users on the Raspberry Pi which I have configured for use with samba. We will not discuss user management here as it is well discussed elsewhere. Also note that guests are ok to write to this share. This means that anyone on your home network can read and write from that hard drive.

Once configured save the file and restart samba:

$ sudo systemctl restart smbd


You should now be able to find this share on your MacOS machine by going to the Finder Application and clicking on Network, then on your Raspberry Pi name, then on backups. Once connected to the share it should be mounted as a directory on your MacOS machine. Go to the terminal and run df:

% df -h
Filesystem                                  Size  Used Avail Capacity  iused     ifree %iused Mounted on
/dev/disk1s1s1                             932Gi  14Gi  87Gi   15%   502068 908173400   0%  /
devfs                                      194Ki 194Ki   0Bi  100%      670         0 100%  /dev
/dev/disk1s5                               932Gi 5.0Gi  87Gi    6%        5 908173400   0%  /System/Volumes/VM
/dev/disk1s3                               932Gi 799Mi  87Gi    1%     3696 908173400   0%  /System/Volumes/Preboot
/dev/disk1s6                               932Gi 3.2Mi  87Gi    1%       19 908173400   0%  /System/Volumes/Update
/dev/disk1s2                               932Gi 824Gi  87Gi   91%  2999344 908173400   0%  /System/Volumes/Data
map auto_home                                0Bi   0Bi   0Bi  100%        0         0 100%  /System/Volumes/Data/home
//bresnaha@PIPERPI._smb._tcp.local/backup3 1.8Ti 645Gi 1.2Ti   36% 675862994 1245861680  35%  /Volumes/backup

On my machine we see it mounted as /Volumes/backup. We can now read and write to that directory from the MacOS machine as we would any other directory only it will be stored on the remote hard drive attached to the Raspberry Pi.

Run a Backup

rsync is a tool that looks at two sets of files, compares them, and copies just any found differences from the source to the destination. It is great for keeping copies of large datasets which do not change often synchronized.

rsync can be installed onto MacOS with brew:

brew install rsync

If you do not have brew installed there are instructions to do so here.

Once installed run rsync to copy your photo album to the backup mount we saw above. The first time it is run it will take a long time because it has to copy your entire album. Future runs will be relatively fast because only new pictures and database changes will be copied.

rsync -t -h --progress -i -va ~/Pictures/Photos\ Library.photoslibrary /Volumes/backup

Once the comand completes you will see a copy of your photo album at /Volumes/backup3/Photos\ Library.photoslibrary:

% ls -l /Volumes/backup3/Photos\ Library.photoslibrary
total 352
drwx------@ 1 bresnaha staff 16384 Apr 30 2020 Attachments.legacy
drwx------@ 1 bresnaha staff 16384 Jan 31 2020 Masters.legacy
drwx------ 1 bresnaha staff 16384 Jul 11 2018 Plugins
drwx------@ 1 bresnaha staff 16384 Oct 16 01:08 database
drwx------@ 1 bresnaha staff 16384 Jul 18 06:22 external
drwx------ 1 bresnaha staff 16384 Oct 8 08:13 iPod Photo Cache
drwx------ 1 bresnaha staff 16384 Jan 30 2022 internal
drwx------@ 1 bresnaha staff 16384 Apr 25 2020 originals
drwx------ 1 bresnaha staff 16384 Jul 18 06:22 private
drwx------ 1 bresnaha staff 16384 Jan 30 2022 resources
drwx------ 1 bresnaha staff 16384 Jan 30 2022 scopes

This data is on the hard drive connected to your Raspberry Pi now.

Install the Photo Frame Software

The sotware to turn an Apples Photo album into a Raspberry Pi picture frame is here. Installing it first requires a few base libraries to first be installed on your Raspberry Pi. Open up a shell on the Raspberry Pi and run the following commands:

sudo apt install virtualenv python3-virtualenv python3


Once you have the base components run the following steps:

mkdir PhotoFrame
cd PhotoFrame/
git clone https://github.com/buzztroll/buzzipick.git
cd buzzipick/pypicker/
virtualenv -p $(which python3) venv
. venv/bin/activate
pip install -r requirements.txt
python3 setup.py install

The above installs all the needed components and now the picture frame is ready to run. At any time you can run it with:

./venv/bin/buzz-photoframe /media/bresnaha/PIBACKUP/Photos\ Library.photoslibrary/

This will start showing pictures on your Raspberry Pi screen. To stop it push the escape key or the q key.