gyazoはてなフォトライフ版でもpostした画像をクリップボードにコピーするようにしてみた
はてなフォトライフにpostするgyazoを書いた on Mac OSX - Post-itみたいなで書いたものをちょっと改造してみた。
改造箇所
- idファイルは不要なので削除
- オリジナルサイズの画像URLをクリップボードにコピー
- オリジナルサイズの画像URLを開く
ソース
#!/usr/bin/env ruby require 'rubygems' require 'atomutil' tmpfile = "/tmp/image_upload#{$$}.png" imagefile = ARGV[1] if imagefile && File.exist?(imagefile) then system "sips -s format png #{imagefile} --out #{tmpfile}" else system "screencapture -i #{tmpfile}" end imagedata = File.read(tmpfile) File.delete(tmpfile) atom_uri = 'http://f.hatena.ne.jp/atom/' post_uri = atom_uri + 'post' userid = '****' pass = '****' entry = Atom::Entry.new({ :title => 'post by gyazo', :updated => Time.now, :content => Atom::Content.new { |c| c.body = [imagedata].pack('m') c.type = "image/png" c.set_attr(:mode, "base64") }, }) auth = Atompub::Auth::Wsse.new :username => userid, :password => pass client = Atompub::Client.new :auth => auth res = client.create_entry(post_uri, entry, "post by gyazo") # アップした画像のURIを作成する head = userid.slice(0,1) date = res.slice(-14,8) num = res.slice(-14,14) url = "http://img.f.hatena.ne.jp/images/fotolife/#{head}/#{userid}/#{date}/#{num}_original.png" system "echo #{url} | pbcopy" system "open #{url}"
gyazo.app/Contents/Resources/scriptの中身をこれに置き換えて、Mac標準のRubygemsでatomutilをインストールすると使えます。
もしサイズの関係でオリジナルサイズを使用したくない場合は、最後辺りのurlにある"_original"を削除してください。