I really enjoy automating things using Workflow, Hazel, shell scripts, or just about anything else.
Last night I got the idea that it would be cool to have a graphical archive of each post to my website as it appeared the day it was posted. Over time I’ll have a visual history of how my website has changed and, who knows, might make a little coffee table book or something.
The automation for this is fairly simple. I took an existing Workflow I had that used the JSONFeed of my site to grab the most recent post and modified it
- to fetch the URL,
- render it as a PDF,
- convert each page of the PDF to PNG images,
- stitch those images together,
- and then drop that single image to Dropbox.1
When Workflow has finished, I’ve got Image.png
sitting in a directory in Dropbox.
Hazel takes things from here. I monitor the directory looking for new image files matching Image.png
.2 When Hazel sees a file matching this pattern it trims the file of whitespace3 and uses pngcrush to compress the resulting PNG as small as we can get it.4 From there, Hazel renames the file and we’re all done.
Nothing in this automation is groundbreaking or difficult, but it was a fun little project. Without iOS being involved in the process I could have used a small daemon to monitor my JSONFeed and something like webkit2png to generate the initial image. That might be something I try in the future, but for now I really enjoy pressing the button in Workflow to kick this process all off.
convert Image.png -trim Image.png
Hazel Shell Syntax ↩︎pngcrush -brute -ow Image.png
Hazel Shell Syntax ↩︎