An intro series to scripting Capture One, with Ben Liddle

Splitting hairs: Variants v. Images

The thumbnails in Capture One’s browser pane are technically variants. A variant is a unique set of rendering instructions for a given source raw (or TIF, JPG, etc) image file. These instructions are lightweight (few hundred Kb at most), so you can think of these as virtual copies of your image files. Every image file you view in Capture One has at least one variant; unless you objectively create a new variant, there’ll be a 1:1 ratio of variants and images in your browser.

Setting up the Handler

Below is the code to set up the AS hander. Create a new script file and save this to the top of the file. Handlers are basically bits of code that you can call from anywhere else in the code (once you have already defined it, thus putting this at the top). They start with the on keyword, and are called with my (when they’re located in the same .scpt file as the code that’s calling it, but you can ignore this for now).

Let’s break it down:

Here, I’m declaring that we’re creating a handler arbitrarily called select_vars. The bit in parentheses is a parameter that I’m declaring. Basically, when we call this handler later on, we’ll be passing a variable as well. The ‘as string’ tells the script that whatever I pass to select_vars later on, it must be a string; eg if later on I pass it an integer or list, we’ll get an error.

The color tags in Capture One are scripted to numeric values between 1 and 7. Here, I’m building a list of readable color tag names in their order: a red tag is actually a 1, a green is actually a 4, etc.

Repeat with a variable i, from 1 to the length of (ie count) of the color tag list. On each loop through (iteration), i is the index (position) of the item in the list.

Here we’re checking if the item in position i is the same as the text variable I’m setting. If so, create a new variable called color_tag_number and set its value to the current iteration’s value of i.

Collect all variant objects of the current collection whose property color tag’s value is equal to the value of color_tag_number . Create a new variable, sel_vars, to store references to them. Since we used the plural of variant, our variable sel_vars is a list.

The current document is being told to select the variant objects referenced in sel_vars. This is actually an additive select- if we had four other variants selected, we’d have the count of green-tagged images plus those four selected. This can be prevented by throwing in a deselect command before the new select command:

With this handler set up, we can call it wherever we want in the script without repeating the code block:

Et voila. Variants selected.

Ben Liddle is a data manager in Colorado who automates the shit out of the first half of the work/life balance so the second half can be more fun.