I'm currently developing a small script to take screenshots and upload them to imgur using Python.
The code looks like this:
import time
import os
import ImageGrab
import urllib
import urllib2
time.sleep(1)
shot = ImageGrab.grab()
dir = os.path.join(r'C:\SAMPLE\PATH', 'Screen ' + time.strftime(r'%Y-%m-%d %H-%M-%S') + '.png')
shot.save(dir)
data = urllib.urlencode({"key":'MY_API_KEY', "image":urllib.quote(open(dir,'rb').read().encode("base64"))})
site = urllib2.Request("http://imgur.com/api/upload.json", data)
s = urllib2.urlopen(site)
print s.read()
I get a response from imgur but when I open the link I get a blank image (though its resolution is correct). I think the base64 encoding method may be off but I'm at a loss.