DIY photography tools

Follow the Script

Author(s):

DIY tools and shell scripts can make for a smooth photographic workflow on Linux.

Photographic workflow is more than just keeping tabs on your photo library and processing RAW files. There are plenty of other tasks you might want to manage: from backing up RAW files and photos when you are on the move, to publishing your best work on the web.

Developing custom tools that keep a photographic workflow smooth is arguably as much fun as taking photos. So for several years now, I've been working on a number of simple applications and scripts that I use on a daily basis. All the tools described in this article are released under the GPLv3 license.

Little Backup Box

When you are traveling, having a backup of all your photos and RAW files makes a lot of sense. Even if your camera has two card slots, it still pays to have a separate backup on a different storage media. Of course, you can spend serious money on something like WD My Passport Wireless SSD. Aside from the price, this otherwise clever device has one major drawback: You can't tweak, extend, or upgrade it. Theoretically, you can upgrade storage, but doing this requires neurosurgery-level skills and most certainly voids the warranty. And as soon as the battery inside the device dies, you are left with an expensive paperweight.

Instead of paying through the nose for a commercial product with limited functionality and a nonexistent upgrade path, you can easily transform a Raspberry Pi into a simple yet versatile backup device using Little Backup Box [1].

Opting for the DIY solution offers several advantages. To begin with, Little Backup Box is based on mature and reliable open source tools. Depending on your skills, you can customize, extend, and improve Little Backup Box to meet your specific needs. For example, with a bit of work, you can implement cloud backup functionality, add hardware buttons to trigger a backup action, and much more.

Little Backup Box is designed to run on a Raspberry Pi, which is by far the most popular single-board computer on the market. You can buy it, along with the rest of the required parts, from practically any reputable store. Using the available parts, you can build a tiny Little Backup Box device based on a Raspberry Pi Zero that fits any pocket and can be powered by a small power bank (Figure 1). Or you can opt for a more powerful and versatile device based on Raspberry Pi 3. Better still, thanks to its modular design, you can easily replace the battery, upgrade storage, and swap any faulty component. More importantly, Little Backup Box comes with a script that automates the entire installation and configuration process.

Figure 1: Little Backup Box can be powered by a power bank and controlled via a web interface.

To build your own photo backup device, you need three things: a Raspberry Pi, a power supply or power bank, a microSD card, and a high-capacity USB drive that will act as a backup storage device. Theoretically, it's possible to use Little Backup Box with a conventional hard disk or solid-state drive, but you need to either use a powered USB hub or a hard disk with its own power source.

Transforming a Raspberry Pi into a photo backup device is a three-step procedure. First, create a bootable microSD card with the Raspbian Lite system on it. Second, boot the Raspberry Pi using the created card, run the raspi-config tool and configure the system. Also, edit the /etc/wpa_supplicant/wpa_supplicant.conf file to connect the Raspberry Pi to the desired wireless network. Third, run the command

curl -sSL https://is.gd/littlebackupbox | bash

to install Little Backup Box. That's all there is to it.

Little Backup Box supports three backup modes: Card backup (automatically backs up the contents of a storage card to an external storage device), Camera backup (transfers photos, RAW files, and videos from the camera connected directly to the Raspberry Pi), and Remote control (access all features via a web interface). The first two modes make it possible to run backup operations without user interaction, while the Remote control mode allows you to activate any of the two modes manually. In addition to that, the Remote control mode allows you to enable the DLNA and Samba servers, view system info, and shut down the Raspberry Pi.

During installation, the installer prompts you to choose the default mode. If you want to use Little Backup Box strictly as a backup device, choose either the Card backup or Camera backup mode. To access all the available features, choose the Remote control mode.

Using Little Backup Box in the Card backup or Camera backup modes couldn't be easier (Figure 2). Boot the Raspberry Pi and plug the backup storage device into it. Depending on which mode Little Backup Box operates in, connect either a card reader with a card or your camera. The backup operation then starts automatically, and the Raspberry Pi shuts down as soon as the backup is complete.

Figure 2: Little Backup Box features a simple web interface.

In the Remote control mode, the Raspberry Pi connects to the specified wireless network, and you can access Little Backup Box's web interface using any device on the same network. Point the browser to http://ipaddress:8000, where ipaddress is the IP address of the Raspberry Pi, and you should see Little Backup Box's web interface.

Otto

When it comes to transferring RAW files and photos from a storage card or directly from your camera, there are plenty of tools at your disposal: from dedicated tools like Rapid Photo Downloader, to the Import module in digiKam. Although these tools excel at what they do, they might not always fit your particular needs. For example, I prefer to store important information about a photo in the Exif metadata Comments field. The information includes the camera model, lens, and weather conditions. This way, when I view the photo in digiKam, I can immediately see what camera and lens combination I used to take the photo and what the weather was on that particular day. I also wanted to streamline the import procedure, so it would not only transfer files, but also geotag, rename, and organize them by date – all in one go.

The Otto shell script [2] does all of this with practically no user interaction. During the first run, the script prompts you to specify the required info, such as the destination directory for the transferred RAW files and photos, the desired copyright notice, a key for the Dark Sky weather service API, and a Notify key. After that, using Otto to transfer RAW files and photos from a storage card is as easy as it gets. Plug a card reader with a storage card into your machine, mount the card, and note the path to it. Run the command

./otto.sh /path/to/card [OPTION]

(where /path/to/card is the path to the mounted card). If you run the script without any options, it assumes that the photos it's about to import are already geotagged. If the photos are not geotagged, you have three options. Using the -g followed by the name of the city where the photos were taken, you can do coarse geotagging. If you have a GPX file, you can specify the path to it with the -c parameter, and the script geo-correlates the photos for you. And in case you have multiple GPX files spanning several days, use the -m parameter followed by the path to the folder containing GPX files. This instructs the script to merge the GPX files before performing geo-correlation. Once RAW files and photos have been transferred and geotagged, the script obtains the required info and writes it, along with the specified copyright notice, into the appropriate fields in Exif metadata. Once this task is completed, the script renames the transferred files and neatly organizes them by date. Finally, if you've provided a Notify key, the script sends a notification to your Android device running the Notify app [3] to let you know that the import process is finished.

To install the script, clone the project's Git repository using the command

git clone https://gitlab.com/dmpop/otto.git

or download the latest version of the script from the project's page. On openSUSE, move the otto.sh script to the ~/bin directory. On other Linux distributions, you can install the script using the following commands:

sudo cp otto.sh /usr/local/bin/otto
sudo chown root:root /usr/local/bin/otto
sudo chmod 755 /usr/local/bin/otto

Finally, install the required packages. On openSUSE, this can be done using the command:

sudo zypper in getopt bc jg curl ExifTool

Konbini

There are plenty of reasons to like KDE. One of them is the ability to add context actions to the Dolphin file browser. Need to quickly resize a photo directly in the file browser? Create a context action, and you can resize any photo by right-clicking on the file and choosing the action. Need to upload a photo to your blog? Create another action, and you are good to go.

While the process of creating custom context actions is not particularly complicated, it does consist of several steps. If you'd rather not spend time on that, you might want to give Konbini [4] a try. This is a collection of actions that let you perform several useful actions (Figure 3): resizing and recompressing photos, renaming photos using Exif metadata, and converting RAW files into JPEG format. In addition to that, Konbini features tools for adding comments to photos, geotagging photos, as well as viewing the currently selected geotagged photo on OpenStreetMap. If you happen to run openSUSE, Debian, or Ubuntu, you can deploy Konbini using a dedicated installer script. Run the command

curl -sSL https://is.gd/konbini | bash
Figure 3: Konbini gives you quick access to common custom actions for working with photos and RAW files.

in the terminal, and it will install all the required packages and files.

Natsukashii

Love it or hate it, Facebook offers a couple of genuinely nice features, one of them being "photos from the past." Every day, Facebook shows you photos you took on this date in previous years. Google Photos and other services have similar functionality, but what if you don't use any of them and still want to receive small photo greetings from the past? Natsukashii [5] comes to the rescue. This tool consists of two parts: a Bash shell script that finds photos taken on today's date in any previous year, and a simple PHP page that displays the results. The shell script relies on standard tools that are available on most mainstream Linux distributions (ExifTool, find, sed, seq, and ImageMagick). This means that you can deploy Natsukashii on practically any machine running a modern Linux distro. With a little bit of work, it is also possible to run Natsukashii on a NAS appliance.

Installing Natsukashii is easy. Clone the project's repository using the command:

git clone https://gitlab.com/dmpop/natsukashii.git

Alternatively, download the latest version of the source code as an archive from the project's page. Then install the required packages. To do this on openSUSE, run the command:

sudo zypper in exiftool ImageMagick php7

The PHP part of Natsukashii offers password protection, and you should change the default password before you start using the tool. To do this, replace the default password in the protect.php and login.php files in the natsukashii/www directory. Keep in mind that the underlying password protection mechanism is relatively simple, so you shouldn't rely on it as a sole protection for your private photos.

Similar to Otto, Natsukashii prompts you to provide the required info during first run, and after that it works without any user interaction. While Natsukashii does the job, it isn't particularly fast. The script goes through the specified directory and all its subdirectories looking for files with the given extension (e.g., JPG). For each photo found, the script extracts its creation date and compares it with the current date. This process takes time and resources. So if you have several thousand photos on your machine, running the script may take awhile. This means that it might be a good idea to set up a cron job that runs the script during the night.

The script not only finds photos from the past (Figure 4), but it also resizes and places them into the www directory and serves the result using PHP's built-in server on the specified port. Remember, though, that you should not rely on Natsukashii's unsophisticated password protection mechanism to protect your personal photos.

Figure 4: Natsukashii displays photos from the past using a simple PHP-generated page.

Conclusion

When it comes to managing your photo collection, it pays to have tools to make the process go as smoothly as possible, and these four custom tools get the job done.