Flickr Emailr Script

Or “How I survived the Flickr/Yahoo ID merger”

When I relaunched I put together a script that takes a daily screengrab of the homepage and uploads it to Flickr. The plan being that once enough captures accumulated I would do something interesting with them. Four days in I got an email from Flickr telling me that time was running out and that I might as well get my merge on. So I did. And it broke the four day old script.

Now I don’t know how many people need to automate uploading a single daily photo to Flickr—and trust me that’s about all this technique is good for—but I figured I’d share just the same. You’ll need a couple things before we get started:

  • your Flickr upload email
  • Paparazzi!, takes screenshots of webpages using WebKit for rendering
  • CronniX, a GUI for cron
  • OS X, which takes care of the two remaining requirements, Script and

Caveat emptor: I’m no AppleScript guru, I pieced this together from bits of example scripts found in my /Library/Scripts/ folder and around the web. As always, this script is offered as is.

I keep saying script but this is actually a process with two parts: the AppleScript responsible for capturing the homepage, emailing it to Flickr and then cleaning up after itself; and a cron job that tells the script when to run.

Here is my Flickr Emailr Script. It requires a little, self-explanatory configuration:

set email_to to "[email protected]" -- get yours here: [](
set email_from to "[email protected]"
set image_name to "Image Name"
set flickr_tags to "tag1 tag2 tag3 etc"

set capture_url to ""
set capture_delay to 0 -- in seconds, increase to allow JavaScript to manipulate the page before capture
set capture_size to {1024, 768} -- minimum image size, will expand to include entire page as necessary

-- everything below this point you can leave alone --

do shell script "date '+%Y-%m-%d'"
set current_date to the result
set image_path to ((path to pictures folder) as string) & image_name & " " & current_date & ".png"

tell application "Paparazzi!"

    capture capture_url min size capture_size delay capture_delay
    repeat while busy
        -- do nothing --
    end repeat
    save as PNG in image_path

end tell

set image_file to image_path as alias

tell application "Mail"
    set new_message to make new outgoing message with properties {subject:"tags:" & flickr_tags}
    tell new_message
        -- set visible to true --
        set sender to email_from
        make new to recipient at end of to recipients with properties {address:email_to}
        make new attachment with properties {file name:image_file} at after the last paragraph
        -- activate --
    end tell
    send new_message
end tell

tell application "Finder"
    delete image_path
end tell

Some quick notes: image_name will automatically have the current date appended (eg. 2007-02-03). The captured image will be saved temporarily to the root of ~/Pictures/ before being attached to an email, sent, and finally deleted. (I always keep open on my machine so the script doesn’t quit upon completion.)

Download the script and open with Script, edit the first eight lines and run the script once or twice to make sure everything is working. Then “Save as…”, choose an appropriate name, select “application” from the “File Format” drop-down, check “Run Only”, uncheck “Startup Screen” and click “Save”.

Next launch CronniX and click the “New” icon. Switch to the Simple tab and check “All” for “Day of month” and “Month” (“Day of Week” should already be checked). If you leave “Minute” and “Hour” alone, this task will run at 12 am on the dot.

An example of a properly configured task in CronniX

Type open file:// into the “Command” input and then drag your newly created AppleScript app onto the input after the text. That will result in something similar to:

open file:///Users/<username>/Documents/AppleScripts/Si10 Flickr

If the path contains spaces in it they need to be encoded as \\%20 (if the app doesn’t run as scheduled it could be a path encoding issue).

open file:///Users/<username>/Documents/AppleScripts/Si10\\%20Flickr\\

Finally, click the “New” button then click the “Save” icon on the main CronniX window. You’re done. Now we sit back and wait (for all of our accounts to go NIPSA)!

The Flickr Emailr Script has been downloaded 476 times.

Flickr, cURL, & my new Yahoo ID
An interview with Andrew Sutherland
Shaun Inman
February 3rd, 2007 at 11:42 am
The Site