Remotely controlling digital cameras with gPhoto
In Charge
Commercial software that lets users remotely control their camera usually is not available for Linux. gPhoto gives users a free alternative.
Some vendors offer commercial add-ons to help users remotely control their cameras – for example, to take a series of photos at set intervals. Time exposures of the night sky and time-lapse photos of a growing plant are excellent choices of subject as well. However, vendors such as Canon and Nikon only offer their software for Windows and the Mac OS, and Nikon even charges for the program [1]. To make things worse, the software is closed source and not suitable for scripting, which tends to restrict its usefulness.
gPhoto
The gPhoto [2] project mainly comprises the libgphoto2 library, the gphoto2 command-line interface, and the gtkam front end (see also the "Gtkam Graphical Front End" box). The software lets users read and change the status of their digital cameras, copy files in both directions, and remotely control digital cameras.
As of this writing, gPhoto supports more than 1,100 digital camera models. A lack of cooperation on the part of camera manufacturers has forced developers to reverse engineer most of the protocol information and explains why the software does not support all of the features that are available on every single digital camera.
Although most state-of-the-art digital cameras that support simple tasks – such as transferring images – use the popular Picture Transfer Protocol (PTP) standard, the remote control protocols are typically undocumented. The examples in this article have been tested on a Canon 50D and should work with any digital camera supported by gPhoto with slight modifications (especially with Canon models).
Gtkam Graphical Front End
The gtkam graphical front end (Figure 1) currently has only a rudimentary set of functions, although it does vastly simplify image downloads. From the drop-down menu, you can select the connected digital camera and use the thumbnails to navigate through your collection of images. Gtkam does not support remote control functionality for digital cameras. Applications such as the KDE digiKam [3] tool offer more convenience than gtkam.
Data Management
Before you start working with gPhoto, determine whether your camera's transfer mode is set to PTP; otherwise, the program will not support it. To find out whether gPhoto has correctly identified your camera, type gphoto2 --auto-detect at the console to see the following output:
$ <B>gphoto2 --auto-detect<B> Model Port --------------------------------- Canon EOS 50D usb:
In this example, the software found a Canon 50D. The gphoto2 --summary command provides some basic information about the camera, including the memory card (capacity and space usage), designation, serial number, firmware version, and supported file formats. If you set the --list-files flag, you also get a listing of all the images on the memory card. To download the images, try --get-all-files. Table 1 lists a selection of file and directory management options.
Remote Control
Although file downloads work with some 1,100 digital camera models, remote control through gPhoto works with less than 10 percent [4] of them. Most of the supported models are made by Nikon and Canon, and the function is not available at all for cameras by Samsung, Sigma, and Sony.
The gphoto2 --list-config command lists all supported functions offered by the software for the connected camera. For Canon SLR cameras such as the 50D and 400D, you can add capture=on to get a full list of configuration parameters (Listing 1). The --get-config switch reads all the configuration parameters and their possible values; --set-config assigns a parameter. For example, the command in Listing 2 tells gPhoto to output all available ISO settings.
Listing 1
Listing Configuration Parameters
$ gphoto2 --set-config capture=on --list-config /main/settings/eos-time /main/settings/eos-synctime (...) /main/imgsettings/eos-iso /main/imgsettings/eos-whitebalance /main/capturesettings/eos-exposurecompensation /main/capturesettings/picturestyle (...)
Listing 2
ISO Settings for the Canon EOS
$ gphoto2 --set-config capture=on --get-config=/main/ imgsettings/eos-iso Label: EOS ISO speed Type: RADIO Current: 400 Choice: 0 Auto Choice: 1 100 Choice: 2 200 (...) Choice: 6 3200
To set the ISO value to 1600, simply type gphoto2 --set-config capture=on --set-config eos-iso=1600. The supported values for configuration parameters such as the ISO setting (eos-iso), exposure compensation (eos-exposurecompensation), white balance (eos-whitebalance), or picture style (picturestyle) depend on the camera you are using. The available values for the aperture setting (eos-aperture) are driven by your choice of lens (Listing 3). Also note that the path following --get-config= must match your camera model.
Listing 3
Aperture Settings for Canon EOS
$ gphoto2 --set-config capture=on --get-config=/main/ capturesettings/eos-aperture Label: EOS aperture Type: RADIO Current: 5.6 Choice: 0 1.4 Choice: 1 1.6 Choice: 2 1.8 (1/3) (...) Choice: 24 22
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.