ImageGrab.grabclipboard() returns an Image object. You need to convert it to a known image format, for example jpeg or png, then encode the resulting string in base64 to be able to use it in the HTML img tag:
import cStringIO jpeg_image_buffer = cStringIO.StringIO() image.save(jpeg_image_buffer, format="JPEG") imgStr = base64.b64encode(jpeg_image_buffer.getvalue())
(the answer has been edited to correct a typo).
source share