Processing image files
By: Ben Liddle
Tags: Image Processing, Capture One, Applescript, Process Recipe, Photography

The document object understands the process command. The command itself accepts a single variant, list of variants, image filepath or text. Usually I like to stick to feeding it a variant or list of variants. We also need to specify which Process Recipe to use- which is a text string of the process recipe’s name. The command returns the batch job string identifier (an alphanumeric string) on success, or a text string of an error message if failure. I’m not going to go into specifics on why recipe processes fail.

Some sample code:

use AppleScript version "2.4" -- Yosemite (10.10) or later

use scripting additions on do_process(vars_to_process, recipe_text)

tell application "Capture One 20" set process vars_to_process recipe recipe_text end tell

end do_process tell application "Capture One 20"

tell current document set selected_variants to variants whose selected is true

my do_process(selected_variants, "some recipe name") end tell

end tell

Capture One will process the selected variants with a recipe named “some recipe name”. This is useful, but if we don’t have a recipe named “some recipe name” or the processing fails for another reason, we won’t handle it. Given the process command has a value to return, we can put that into a variable:

use AppleScript version "2.4" -- Yosemite (10.10) or later

use scripting additions on do_process(vars_to_process, recipe_text)

tell application "Capture One 20"

set process_result to process vars_to_process recipe recipe_text return process result end tell

end do_process tell application "Capture One 20"

tell current document set selected_variants to variants whose selected is true

set the_result to my do_process(selected_variants, "some recipe name") if the_result begins with "ERROR" then

log "Process failed!" else

log the_result end if

end tell

end tell

This logs “Process failed!” in the editor if the process failed. Helpful, but what if we want to really, really log some processing info? We can output to a useful file via another handler and good ol’ echo :

use AppleScript version "2.4" -- Yosemite (10.10) or later

use scripting additions on do_process(vars_to_process, recipe_text)

tell application "Capture One 20"

my do_log("Batch started...") repeat with a_var in vars_to_process

set process_result to process a_var recipe recipe_text

my do_log("Started: " & name of a_var & " (" & recipe_text & ")") repeat while queued of a_var is true

delay 0.1

end repeat my do_log("Completed: " & name of a_var & " (" & recipe_text & ")")

end repeat return process_result end tell

end do_process on do_log(text_to_log) set ts to do shell script "date '+%Y-%m-%d %H:%M:%S'"

do shell script "echo " & quoted form of ts & ", " & quoted form of text_to_log & " >> ~/Desktop/process_results.csv" end do_log -- set up our CSV headers first do shell script "echo " & quoted form of "Time, Event" & " > ~/Desktop/process_results.csv" tell application "Capture One 20"

tell current document set selected_variants to variants whose selected is true

set the_result to my do_process(selected_variants, "Untitled Recipe") my do_log("Batch completed: " & the_result) end tell

end tell

This processes all selected variants with a given recipe (“Untitled Recipe” here) and logs the progress to a CSV on your desktop:

Vague photography is my specialty.