Scribbles and Snaps

Linux, Open Source, Photography

Process Photos with digiKam’s Batch Queue Manager and a Bash Script

with 3 comments

One of digiKam’s lesser known features is the ability to link scripts to notifications. At first sight, this may seem like a rather obscure functionality, but it can be put to some clever uses. Say, you want to keep a portfolio of selected photos on a mobile device. Resizing multiple photos to a specified size to make it easier to view them on the mobile device and transferring the processed photos from digiKam to the mobile device manually is not very practical. And this is where the ability to trigger scripts via notifications can come in handy. You can attach a simple Bash script to the Batch queue completed notification, so it’s triggered automatically when the Batch Queue Manager tool is done processing photos.

The Bash script is very simple, indeed. It uses the rsync tool to copy the processed photos from the source directory (in this case, it’s /home/user/Photos/Processed) to the /DCIM/Camera directory on the mounted SD card:

#!/bin/bash
rsync -avz --delete /home/user/Photos/Processed /media/0CFA-5602/DCIM/Camera

Paste the code above into an empty text file and save it as a postprocess.sh file (don’t forget to replace the example paths with the actual paths to the source and destination directories). Make then the script executable using the chmod o+x postprocess.sh command.

In digiKam, choose Settings » Configure Notifications and select the Batch queue completed item. Tick the Run command check box, and enter the path to the postprocess.sh script in the appropriate field. As you might have guessed, this links the script to the notification, so the script is triggered as soon as the batch operation is finished.

Next, create a tag (e.g., transfer) in digiKam and assign it to the photos you want to transfer to the mobile device. Alternatively, you can use a specific color label for that. Use then the Filter right sidebar to display the tagged or labelled photos, select them, and press Ctrl+B (or choose Tools » Batch Queue Manager) to add them to a new batch queue. In the Queue Settings section, click on the Target tab and select the Photos » Processede sub-album. Under the Base Tools tab, double-click on the Transform » Resize tool to add it to the Assigned Tools section. In the Tool Settings pane, specify the desired length. You can choose between several presets, or enable the Use Custom Length option and specify the desired length.

Hit then the Run button, and once the batch operation is completed, the assigned Bash script copies the resized photos to the mounted SD card.

You can tweak the script to perform other post-processing actions, too. For example, if you use the llgal command-line tool to generate static HTML photo galleries, you can tweak the script to add the processed photos to an HTML album. The script may look something like this:

cd /home/user/Photos/Processed
llgal --exif --li -L --sx 800 --sy 600

In other words, you can do all kinds of clever tricks by linking scripts to notifications.

Written by Dmitri Popov

2011/07/11 at 08:20

3 Responses

Subscribe to comments with RSS.

  1. Oh, this is neat. I have a couple of bash scripts I run after manually adjusting and saving to output directories. Also, I’ve just got an Android tablet

    Tangentially: it would be awesome to have a Digikam accessory app on that tablet just for doing triage and tagging. Something that could write sidecar files and that could sync with Digikam’s database. Android itself and the app base are lagging far behind the iPad in several photo-management respects, which is frustrating when the Asus Transformer has an IPS screen. Being ridiculously stubborn, I got a remote desktop app working and tried running Digikam over that to see if I could sort photos from the couch instead of at the desk. It was a bit of a silly exercise, but I get that way with new toys.

    a chris

    2011/07/13 at 15:42

  2. Very useful, thanks.
    But maybe you’d want to use this command:
    rsync -av –delete /home/user/Photos/Processed/ /media/0CFA-5602/DCIM/Camera
    no compression (same host) end no subfolder created in Camera.

    acsaf

    2011/07/18 at 08:54

  3. That is an excellent tip!
    I had never noticed this feature !
    Thanks for sharing it

    Vincent Tassy

    2011/07/23 at 04:50


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 368 other followers

%d bloggers like this: