· Pretty Good Hat · archive · about·

Early Summer

 

lightbox2 lightbox2

The days are getting longer, so long that it’s hard these days to convince my nearly-four-year old that, yes, it actually is bedtime. A recent Saturday evening date night found us out and about downtown and I made a few pictures. The Hotel Monte Vista is, of course, a totemic downtown Flagstaff photo; and this old GMC truck reminded me a bit of my grandfather’s ‘53 Chevy pickup back home.

Since last summer I have been using Koken for image hosting and presentation here at Pretty Good Hat. It’s nice: Pretty interface, Lightroom publishing service, and produces nice galleries. Unfortunately, since my host change, uploading into Koken has frequently failed and we haven’t been able to track down the cause.

I tooled around last weekend to come up with an alternative. Although I like it the built-in gallery publishing feature in Koken, I have not used it much, instead using Koken primarily just to serve up images in multiple sizes for posting here1. So I went thinking about what I could replace that with. I started with Jeremy Friedl’s run any command plugin for Lightroom. Unlike the stock Lightroom function for running a script of application after an export, Run Any Command can work both with individual files and a list of all the files in an export, which makes it great for my purposes where I don’t want to do much file management on my own: Using Run Any Command, I can limit my processing to just the selected files without needing to keep track of previous exports that might have put output files into the same directory.

With Koken, I usually publish images to a gallery and then later return to incorporate the published photos into a blog entry. This is often on my iPad, where I use an Editorial workflow to process Koken embed URLs into markdown and then kickoff the blog preview/publish functions. So when I thought about a replacement, I knew I would want some kind of capability to ease that process — but without the nice Koken library viewer I’d need something to help me identify images and filenames.


Turns out something that does just the trick is built into ImageMagick: The montage command, as written up in great & helpful detail by Pat David, can build a nice contact sheet, or, for my usage, a tiny reference gallery that I can deposit in dropbox and quickly reference. And with a bit more code, I can add that single gallery sheet — a set of thumbnails, basically — to a dirt-simple HTML page that includes the image filenames and titles for further use.

The code

In case you’re curious, here’s how it works2. This is part of a Hard Drive export preset using Run Any Command. First there’s the Command to execute. This takes the exported file (set to appropriate size for my “fullsize” lightbox view in the LR export settings) and makes a smaller image for the blog link:

cp '{FILE}' '{NAME}'-small.JPG
/usr/local/bin/mogrify -resize "300x300>" '{NAME}'-small.jpg 
echo '<li> {name}\t{Title}' >> ~/Desktop/contact_sheet_list-$(date +%y-%m-%d).txt

And then the Command to execute upon completion takes care of the tiny gallery and file handling:

/usr/local/bin/montage -label '%f' -font '/System/Library/Fonts/Helvetica.dfont' -background '#000000' -fill '#ffffff' -pointsize 10 -define jpeg:size=200x200 -geometry 200x200+2+2 -auto-orient {FILES} ~/Desktop/contact_sheet-$(date +%y-%m-%d).jpg
echo '<img src="contact_sheet-'$(date +%y-%m-%d)'.jpg"<br>' > ~/Desktop/contact_sheet-$(date +%y-%m-%d).html
cat ~/Desktop/contact_sheet_list-$(date +%y-%m-%d).txt >> ~/Desktop/contact_sheet-$(date +%y-%m-%d).html
rm ~/Desktop/contact_sheet_list-$(date +%y-%m-%d).txt
rsync -e "ssh -i mysshkey" /Users/alan/Pictures/Exported\ Photos/tgal/*.jpg me@server:path/
rsync -e "ssh -i mysshkey" ~/Desktop/contact_sheet-*.html me@server:path/
rsync -e "ssh -i mysshkey" ~/Desktop/contact_sheet-*.jpg me@server:path/
cp ~/Desktop/contact_sheet-$(date +%y-%m-%d).{jpg,html} ~/Dropbox/tgal
rm ~/Desktop/contact_sheet-$(date +%y-%m-%d).{jpg,html}

Again, all of the montage work is cribbed from Pat David; do check out his great site. The rest is my remarkably inelegant handling of the resulting files and concatenation of filenames into a list from which I can copy filename and title/caption into a post. On the writing side, I have a textmate snippet and an editorial workflow to grab that title+caption string from the clipboard and paste their respective parts into a kramdown-flavored image link:

[![lightbox2](http://prettygoodhat.com/PATH/image-small.jpg)](http://prettygoodhat.com/PATH/image.jpg){:id: .lightview data-lightview-group="GROUP" data-lightview-group-options="controls: 'thumbnails', viewport: false" data-lightview-caption="title" }

It’s ugly, I know. But send that through kramdown and it gets the right Lightview styling and everything. So it’s actually pretty hot. I’m grateful to Pat David and to Jeremy Friedl for documenting and building, respectively, some of the tools that help me do this. Jeremy is a long-time Lightroom plugin developer”) and I’ve happily supported his plugins in the past — now that I’m enjoying photography more again, it’s time to re-up!


  1. I use Lightview for a lightbox-style presentation. [return]
  2. This explanation is really so I remember how I did this in the future. [return]