クリップボードから画像を取得

2017/07/30

Python 2.7.10, PIL4.2.1

# -*- coding: utf-8 -*-

from PIL import ImageGrab, Image

im = ImageGrab.grabclipboard()
if isinstance(im, Image.Image):
    im.save('tmp.jpg')
    print('saved')
else:
    print('no image')


IOError: Unsupported BMP bitfields layout
が出るときは、バージョンをアップデート

How to copy a image from clipboard in Python?
http://stackoverflow.com/questions/35254655/how-to-copy-a-image-from-clipboard-in-python/35254949

Problem with saving image from clipboard
https://github.com/python-pillow/Pillow/issues/1293