“God’s Own” AppleScript?

AutomatorAbout a year ago, when Tiger was in Public Beta, Thies told me to check out Automator. I didn’t get around to it because Thies is in the habit of saying things like, “Skype is God’s Own phone.” When everything is “God’s Own” X, then saying something like, “Automator is cool” isn’t going to get me jumping onto BitTorrent, especially since I never grokked AppleScript.

Earlier this year, I gave a talk in Vancouver. After Cal, the lead developer of Flickr, complimented me on it, I decided to see his talk. Okay, so his doesn’t have cool Keynote transitions like mine, but in terms of content, it totally rocks. What he and Ludicorp were able to do building Flickr is textbook case of why LAMP rules in the right hands. Go see his talk! I was impressed.

I registered for Flickr.

I then forgot about it until Rose suggested I put my Yosemite photos there. Wow! I was (even more) impressed. The use of DHTML and remote scripting rocks.

This stuff was “God’s Own” online photo album. I should have guessed this since Cal edited Javascipt + CSS + DOM Magic (nice layout and design, btw) but this goes far beyond it. Flickr is the future of web applications. It uses Javascript/Remote Scripting (AJAX) to get most of the feel of a desktop photo organizing application, but then leverages the community features of the Web. The web API abstraction means that there is a healthy 3rd party of applications that integrate with Flickr.

I bought a pro account.

There was one major wart I’ve run into. Flickr loses color space information on resize. It took me a couple days to figure out on my own why my photos (16-bit ProPhoto colorspace) were getting desaturated.1 Also, for the geek in me, there is no support for JPEG 2000).

I also can’t wait until they integrate purchasing prints into Flickr.

While test-driving some of the community aspects of Flickr, I ran across this post which had a clever idea: Design a photo book in iPhoto and upload it to Flickr. He used this to create a flickr album of his daughter’s life so far. The problem was the process sounded time consuming and required Adobe CS2.2

Since Preview supports PDF export, I got a stupid idea of using Automator to fix these problems. Besides, it was an excuse to see what Thies was raving about last year.

In geek-speak, Automator is “Unix pipes for Applescript”, except instead of chaining applications together using the command line, you chain pre-built “Actions” together in Automator to create “Workflows” via a drag-and-drop interface. Starting from this workflow, it took only 30 minutes3 to write a program to take a PDF, turn it into JPEGs snapshots of each page and upload them to Flickr. That included the download and install of Frasier Speirs’s Flickr Automator Action.

Automator PDF to Flickr Workflow

You can download the application here (but you will need the Flickr Automator Action mentioned above). Simply drag-and-drop a PDF into the Application and then you will be given three prompts. The first allows you to set the resolution and compression of the JPEG conversion; the second allows you to name the upload files (edit the “new name” text field); the third allows you to set your flickr login credentials, tags, and security level of the uploaded files). If you want, you can drag-and-drop this application into Automator, edit it, and then save it (as a Workflow) into ~/Library/Workflows/Applications/Finder/. Then you can right click and PDF to upload it to Flickr. Neat!

Is it “God’s Own AppleScript?” Not really. There are some issues I ran into already, besides the crappy debugging capabilities:

  1. The workflow has trouble distinguishing type information when chaining workflows (it gives a visual error when binding “Files/Folders” to “Image files”).
  2. The “Move Finder Items” action cannot find your “Desktop” or “Documents” if you turned on FileVault in your Security Preference Pane
  3. Since you can only pass one type of thing from one workflow to another, there is no way I can clean up the temp files created. (The Flickr action returns URLs of the pages it generates), nor is there a way to automatically get the name of the PDF file to assist in automatically renaming the temp images.
  4. It’s still not well documented.

However, I find that Automator will be very useful in the future. Since you can bind shell scripts and AppleScripts as Actions, I’ll definitely be having a closer look at it as time goes on.

I asked Caitlin to whip together a iPhoto book so that I could test to see whether my idea actually works. She took some old, un-retouched photos I have from the Point Reyes hike that destroyed my Olympus and whipped together this 6 page album (click to play):

SeasideWonderland book

1 Even after conversion, I can’t get the perfect settings. I decided make a Photoshop Action to convert my work to sRGB targeting “Saturation” and save as a JPEG (TIFF files lose the EXIF information which Flickr uses for good effect.) Note, colorspace is going to be an issue when people start ordering prints. The RGB gamut is not as wide as your typical CMYK printer.
2 I am holding out on the upgrade since Adobe added product activation to the Mac version. I’ve had bad experiences with activation on the PC version of Macromedia Studio, and a two-computer limit is just not enough when you’ve had a computer stolen. But mostly it is the thought that 10 years in the future I might want to drop a copy of Adobe CS2 on an old computer and I won’t be able to because it can’t dial home to the mothership.
3 It should have taken less. It took me a while to figure out how to debug an Automator action and the error messages in Automator appear and disappear too fast to read. So you don’t have to suffer, the trick is to choose “View > Show Log” from the menu and drop in the “View Results” action around buggy parts of your workflow.

7 thoughts on ““God’s Own” AppleScript?

Leave a Reply

Your email address will not be published. Required fields are marked *