~/.unplanned
August 11th, 2024

Hazel, shell scripts, Kagi's AI Quick Answers, and Magick photo borders

Tools

I was looking around for "resize and add a border" options for photos. Lightroom mobile will do it. There are some iOS apps that will do it. I really wanted to work it into my desktop workflow, though, and the desktop version of Lightroom doesn't have a border option. There are some poorly reviewed apps that might to do it, but none of them seem to think a simple white border is a sufficiently interesting problem to solve, and assume you want, like, a simulated gilt painted frame like you'd find on sale at Michael's.

There was also the GraphicConverter option. I figured out how to add a frame in there but couldn't see how to automate it. Or rather, I saw how I could do batch processing that invoked an action to resize and add a border, but couldn't see how to connect it to one of the standard automation options, like Automator and Shortcuts, or keep out of doing something with AppleScript.

As much as I complain about macOS it is good to have a *nixish user land, because even the GUI-driven automation options like Automator and Shortcuts can understand running a shell script once you figure out how they pass it to the script.

For my purposes, sussing out a script meant dealing with ImageMagick, which is not a routine stop for me. Years and years ago, when I was doing some freelance work, I used IM to build out an ebook production toolchain, but that was one of those "learn once, forget immediately" situations, and I think I did it in the context of rmagick,  anyhow.

So I remembered Kagi has Quick Answers, which just send your query to an AI if you add a "?" to the end. 

That got me: 

magick mogrify -resize '5000x5000>' -bordercolor white -border 100 file.jpg

... and Hazel, which I'm using to automate my "archival prints" workflow out of Lightroom, can run shell scripts on targets. Replacing "file.jpg" with  "$1" for the shell script in Hazel, and including the full Homebrew path to the magick binary was sufficient.

This solution is a little simple because I'm making some assumptions when I pick a target size of 5000 max side length I'd rather not make, but I haven't stopped to confirm the math of what I think is an appealing proportion for the border size. So what I'm doing is good for stuff coming off my M43 cameras, and is merely okay for the X-T5 and (soon) X100VI. I'd rather grab the dimensions of each image, calculate the appealing border width per image, and preserve the original resolution instead of scaling down. Now that the workflow is in a shell script, that's not a hard thing to figure out.