Category Archives: Photography

Photo Slideshows Using Raspberry Pi


At a family event just shy of a year ago I wanted to set up a slideshow (two in fact) to run continuously. The event was outdoors and leaving two laptops exposed to the elements for an extended period of time was obviously not very appealing. Instead a couple of Raspberry Pis together with the feh image viewer proved to be the perfect fit.

System Info

  • Pi: Raspberry Pi 3
  • OS: Raspbian 9 (Stretch)
  • Desktop: LXDE

Feh Installation and Test

First install feh:

apt-get install feh

Then run the following command in the terminal:

feh \
    --recursive \
    --randomize \
    --fullscreen \
    --quiet \
    --hide-pointer \
    --slideshow-delay 6 \

The command line switches are for the most part self-explanatory. The idea is to give feh a directory containing pictures you’ve copied to the Pi and then have it cycle through them randomly, displaying each for six seconds. Other options are documented in the man pages if you’d like to customize the usage.

To exit the slideshow press the Esc key.

Disabling Screen Blanking

By default the screen will blank after a few minutes of mouse and keyboard inactivity. In order to disable the screen blanking we’ll need to modify the lightdm.conf file:

nano /etc/lightdm/lightdm.conf

and add the following line under the [Seat:*] section:

xserver-command=X -s 0 dpms

Auto-Start Slideshow On Boot

To have the slideshow automatically start on boot, first create a small shell script file to hold the feh command:

nano /home/pi/

and paste the following:


feh \
    --recursive \
    --randomize \
    --fullscreen \
    --quiet \
    --hide-pointer \
    --slideshow-delay 6 \

Be sure to make the new shell script executable:

chmod 755 /home/pi/

And finally add it to the pi user’s LXDE autostart file:

echo "@/home/pi/" >> /home/pi/.config/lxsession/LXDE-pi/autostart

When you reboot your Raspberry Pi it should now automatically start the slideshow.

To exit the slideshow, hit the Esc key and you will see the normal LXDE desktop.

Extracting RAW Photo Exif Data With Python


I’ve always enjoyed taking pictures. Before smartphones put a camera in everyone’s pocket, I would use whatever (usually cheap) camera was handy. More recently I decided to get more into taking “real photographs” instead of just pictures. As anyone will tell you taking the dive into photography, there is much more complexity than you would normally expect, particularly when compared to point-and-shoot or smartphone cameras. As part of the journey, you will inevitably need to work with RAW image files. While RAW files provide much more information to work with, you may find support for different manufacturers RAW format lacking in tools and libraries that you may have used in the past. This post briefly covers extracting Exif metadata from most RAW file formats with python.

bug photo


We will be using pyexiv2/py3exiv2 for this example, which are python wrappers around the exiv2 C++ library that does the actual image file processing.

  • pyexiv2 is the python 2.x version of the library
  • py3exiv2 is the python 3.x version

The code snippet below will work with with either pyexiv2 or py3exiv2.



For Python 2.x, the current Debian stable as of this writing (Debian 9 Stretch) already includes pyexiv2 in its package repository, you only need to run:

apt-get install python-pyexiv2


For Python 3.x, since the py3exiv2 isn’t available from apt, you’ll need to build it locally. To do this you’ll need to install some prerequisites:

apt-get install \
        build-essential \
        python-all-dev \
        libboost-python-dev \

Then use pip3 to download, build and install py3exiv2:

pip3 install py3exiv2

The following code snippet will:

  • Read a file given on the command line
  • Print all Exif tags found in the file
  • Print a specific tag value


#!/usr/bin/env python3

# usage: <file>

import sys
import pyexiv2

file = sys.argv[1]

md = pyexiv2.ImageMetadata(file)

# print all exif tags in file
for m in md.exif_keys:
    print(m + "=" + str(md[m]))

# print specific tag 
aperture = float(md['Exif.Photo.FNumber'].value)
print("Aperture: F{}".format(aperture))

Note 1: One thing to keep in mind is that different Exif keys will return different value types. For example Exif.Photo.FNumber returns a Rational type which was converted above to float to print how aperture is commonly expressed. The ‘Exif metadata reference tables’ link in the References section has a list of tags and their respective types

Note 2: Different RAW file formats (.ARW, .CR2, .NEF, etc) will often have a different set of Exif tags, particularly for lesser used/uncommon ones (for example Exif.Photo.LensModel).

Example Run

$ ./

Exif.Photo.ExposureTime=<Exif.Photo.ExposureTime [Rational] = 1/125>
Exif.Photo.FNumber=<Exif.Photo.FNumber [Rational] = 40/10>
Exif.Photo.ISOSpeedRatings=<Exif.Photo.ISOSpeedRatings [Short] = 1600>
Aperture: F4.0


If you’d like to experiment in a Docker sandbox, the following Dockerfile will spin up a docker container with py3exiv2 and run the script:

FROM python:3.6-stretch

RUN apt-get update && \
    apt-get install -y \
        build-essential \
        python-all-dev \
        libboost-python-dev \

COPY \ \ \

RUN pip3 install py3exiv2

CMD [ "python3", "./", "" ]


  1. Exiv2 project:
  2. py3exiv2 project:
  3. EXIF metadata reference tables:
  4. EXIF tag value chart: