Created
July 16, 2011 22:38
-
-
Save pdxmph/1086882 to your computer and use it in GitHub Desktop.
Export Frontmost Acorn to PNG, Upload to imgur, Get URL back to clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "rubygems" | |
require "imgur" | |
require "appscript" | |
include Appscript | |
# get your imgur API key here: http://imgur.com/register/api | |
imgur_api = "xxxxxxxxxxxxxxxxx" | |
acorn = app("Acorn") | |
# [0] is always the frontmost document | |
img = acorn.documents[0].get | |
basename = File.basename(img.name.get, '.*') | |
export_path = "/tmp/#{basename}.png" | |
img.web_export(:in => export_path, :as => :PNG) | |
i = Imgur::API.new(imgur_api) | |
imgur_hash = i.upload_file(export_path)["image_hash"] | |
img_url = "http://i.imgur.com/#{imgur_hash}" | |
# copy the path out to the system clipboard | |
`echo #{img_url}|pbcopy` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment