Phtobx - Use Raspberry Pi to manage your photo library

Phtobx is a system that allows you to manage and sync your photo library. The main component is a Raspberry Pi (or other Linux device) acting as a NAS and syncing photos to and from Eye-Fi and Dropbox.

Photos are added to Phtobx via the network drive (Samba), via Eye-Fi/FTP, or via Dropbox upload from your cell phone. Phtobx then creates downscaled versions of the photos that are available on a network drive on the local network and through a web interface. Outside of the local network photos, are available on Dropbox.

If a photo is deleted from one place all versions of that photo are removed. New photos or deletions are synced automatically.

Features
- Home network access via Samba and local web server.
- Access from everywhere via Dropbox.
- New or deleted photos are synced automatically.
- Scaled down versions of photos created to ease access.
- All files stored in ordinary folders on removable media that can be plugged into an ordinary computer for backup and organisation.

What you need
- A Raspberry Pi
- An Eye-Fi card
- A Dropbox account
- An FTP account

NB This software is not thoroughly tested and might not work as intended. Use at your own risk.

SET UP YOUR RASPBERRY PI

  1. Get the latest Raspbian wheezy distribution (install via NOOBS)
  2. Reduce GPU memory usage to the lowest option typing sudo raspi-config and selecting "Advanced options" > "Memory Split"" and input 16
  3. Consider giving your Raspberry Pi a static IP address for access via non-windows devices.

SET UP PHTOBX

  1. Download and unpack Phtobx files:
    wget http://f9.no/phtobx/phtobx.tar.gz
    tar -xzf phtobx.tar.gz
  2. Set up your Eye-Fi card to push photos to your ftp server and update phtobx/config.py with details for your ftp server
  3. Go to http://www.dropbox.com/developers/apps and create a "Dropbox API App" with access to files and datastores, not limited to its own private folder (to enable photo download sync), with specific file types set to images. Give it a name (e.g. "your name phtobx"), and copy the values for App Key and App Secret to the phtobx/config.py

  4. Update system and install necessary third party packages
    Update the Linux system and install the Python module installer
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install python-pip
    Install lftp (used to download photos from ftp)
    sudo apt-get install lftp
    Install ImageMagick used to convert photos
    sudo apt-get install imagemagick
    Install JHead used to make sure orientation is correct on photos
    sudo apt-get install jhead
    Install Python Dropbox client
    sudo pip install dropbox
    Install Flask (web framework)
    sudo pip install Flask
    Install Samba
    sudo apt-get install samba samba-common-bin

MOUNT USB AND CONFIGURE SAMBA

  1. Ensure that your USB device is connected to the Raspberry
  2. Create folder for share
    sudo mkdir -p /home/shares/photos/
  3. Add mount information to /etc/fstab
    sudo sh -c 'echo "/dev/sda1 /home/shares/photos auto owner,user,iocharset=utf8,umask=000 0 0" >> /etc/fstab'
  4. Reload mounts
    sudo mount -a
  5. Configure Samba by adding the following to the end of /etc/samba/smb.conf
    [Photos]
    path = /home/shares/photos
    create mask = 0660
    directory mask = 0771
    read only = no
  6. Add new user with name "photo" to the Raspberry Pi and to Samba
    sudo useradd photo -m -G users
    sudo passwd photo
    sudo smbpasswd -a photo
  7. Restart the Samba service
    sudo /etc/init.d/samba restart

Further information can be found here.

CREATE FOLDERS

  1. Ensure that folder for logs etc are writable
    chmod 777 phtobx/.
    chmod 777 phtobx/*.*

  2. Create folders for storing the photos (folders as defined in config.py)
    sudo chmod 777 /home/shares/photos/
    mkdir /home/shares/photos/original
    mkdir /home/shares/photos/medium
    mkdir /home/shares/photos/thumb
    mkdir /home/shares/photos/_trashcan
    mkdir /home/shares/photos/_camera
    mkdir /home/shares/photos/_phone

  3. Create a symbolic link between web root and photo share
    ln -s /home/shares/photos/ phtobx/static/img

  4. This is probably a good time to reboot your raspberry pi
    sudo reboot (somethimes also windows machines needs a reboot before they can find new samba drives)

UPDATE CONFIG FILE

VERIFY INSTALLATION

  1. Run 'python phtobx/sync.py' and follow instructions regarding authorizing to Dropbox.
  2. Put some photos in the folder of the ftp server and in the original folder (which now should be accessible as a network drive on your system) and run the script again.
  3. Run 'sudo python phtobx/httpd.py'
  4. Point your browser to http://<ip-address-of-your-raspberry-pi>

ADD TO CRONTAB

If everything seems to be working it is time to add the scripts to the crontab to make sure that they run automatically

Add the following entries to your crontab
*/5 * * * * python /home/pi/phtbox/sync.py >> sync.log 2>&1
@reboot sudo python /home/pi/phtbox/httpd.py > /dev/null 2>&1 &

There is good explanation of how to add stuff to crontab here.

Explanations:
Line 1: Runs the main Python script that synchronizes with Dropbox/Eye-Fi and creates thumbnails every 5 minutes.

Line 2: Starts the Flask http service. Needs to run as root since the http service is using port 80.

sudo reboot

ADDITIONAL INFORMATION

SECURITY

None

CREDITS

LICENSE

Phtobox is licensed under MIT

Download source

 

Created by Arne S, a@f9.no. Last updated 2014-02-04.