September 2009

Tethering from your Nikon to your Linux PC

If you're using Windows, you can buy some software from Nikon to have Photo Tethering (I guess it's called Tethering). I.e. you take a picture with your camera and it pops up on your computer screen. It's used in studio photography and very useful. I missed it very much during the last three days of product photography.

I wanted to have that on Linux as well. There is an excellent library called gphoto2, that can do half of the trick (i.e. it can download a picture right after the shot), but it can't display it. So I played around a little bit and wrote that script:

#!/bin/bash

case "$ACTION" in
    download)
        pkill qiv
        qiv -l -f -m "$ARGUMENT" &
        ;;
    "")
        me=$(cd ${0%/*} && echo $PWD/${0##*/})
        gphoto2 --capture-tethered --hook-script=$me
        ;;
esac

To "install" it, place it somewhere on your path.

To use it, connect your Nikon camera to your computer via USB. Go to an empty folder in a shell and just start it:

rian@thunder:~Pictures/example$ tether

Then take pictures. They will be displayed on your screen and stored in your current folder.

For this to work, you need the image-viewer qiv (or use any other viewer and adjust the script) in its most recent version (older versions don't support the -l switch which autorotates the image), if you're using ubuntu jaunty, you need to install qiv from karmic.

And you have to install gphoto2 to access the camera as well.