Blog

Two small photography-related scripts

I just added a couple of small photography-related scripts to Github – one for photo organisation, and one for generating preview galleries. Every photographer has their own workflow, so these are more useful as starting points for your own tools rather than something to use out of the box. They're easier to adapt with some backstory.

How I sort my photos

When I finish a photoshoot1, I copy the photos into a directory with a datestamp and a title. For instance:

  • 20190617 - Raptors victory parade
  • 20190728 - fire spinners
  • 201911 - Thailand

Next, I pick the photos I want to edit. I use macOS' filesystem tags to organise these into two categories – "definitely" (for my best shots) and "maybe" (for shots with potential). Tags are great:

  • They're part of the OS – so you can use them in searches, in file → open dialogs, and so on. One click in the Finder sidebar shows me my edit queue.
  • You're not locked into one app for organisation, making it easier to change apps or use multiple editors.
  • Your tags get backed up as part of your regular Time Machine backups.
  • Tags are attached to individual files, so if you copy photos to an external drive the tags are copied too.
  • You can interact with tags programatically, so you can build your own tooling on top of them.

The Finder's built-in tools are enough to sort through my photos from small photoshoots. Open a Finder window, switch it to thumbnail mode, maximise the zoom, and resize to get two photos per row. Then select a file, and press space to open Quick Look to check out the photo. If you like it, right-click → click a tag to add.

A screenshot of a Finder window, showing the maximum zoom for filtering images

This doesn't work so well for larger photoshoots. It isn't easy to winnow down your selections2, and you move between the keyboard and the mouse a lot.

I use Affinity Photo as an image editor, and I really like it. But I recently picked up a copy of Exposure X5, mostly for its many film presets/colour grades (including some passable imitations of my camera's built-in presets). Affinity Photo's similar to Photoshop, whereas Exposure's more like Lightroom – which means it's also capable of organising your images and faster winnowing. Load a directory of images, sort through them applying flags/ratings, then filter down to the flagged/rated images and upgrade/remove the ratings to suit. There's keyboard shortcuts for these, so it's potentially faster – though Exposure seems to do a poor job of pregenerating RAW previews, so I've found some frustrating delays.

If you did this in Lightroom, those ratings would be stored in Lightroom's central catalog. Exposure, however, stores all its metadata alongside your files. This makes it much easier to work with programatically! I wrote a small script, tagsfromexposure, which reads Exposure data and creates filesystem tags. Flagging an image as "pick" in Exposure translates to "definitely"; 2 stars or above translates to "maybe". This uses the tag command line utility for tagging, as it looked complicated in standard Ruby.

Generating preview galleries

Once I've picked my photos, I generate a preview gallery for online sharing. If it was a "proper" photoshoot, this lets my model pick their favourites for me to edit; if it was a day out or a trip abroad, I can share the good shots with family & friends. I dislike image editing and I'm a slow editor, so most of my photos would never be seen if I didn't publish these previews.

albumfromtags uses Sigal to generate these galleries based on macOS tags. Anything with a "maybe" or "definitely" tag gets included. This script also uses the tag utility to read filesystem tags. It copies the images to a new directory, uses Sigal to generate the gallery, then removes the temporary directory. You'll need to customise the sigal.conf.py.example file to add your name for the gallery's copyright notice, save it somewhere permanent, and edit the albumfromtags file to point to the config.

----------

One thing I like about these scripts & this workflow is that it's very modular. I've taken several unrelated tools, and used a small amount of code to glue them together so they work for me. They're easy to extend and change. There's no custom data formats involved – just the operating system's features. These are all unixy approaches to building tools – an approach as useful in 2019 as it was in 1989.


  1. This can be an actual photoshoot, or a day out, or a trip abroad, or whatever. I also keep monthly "miscellaneous Toronto" directories for my handful of day-to-day shots around the city.  ↩

  2. For instance, if you have 3 good portraits of someone in a particular pose, there's a lot of clicks and filters needed to tag all 3 as "maybe" and then later upgrade one to "definitely".  ↩

Subscribe via RSS
Follow me on Twitter

browse by date

  • December 2019