Pillow
http://pillow.readthedocs.io/en/latest/
Table of Contents
Installation
Save a clipboard image howto
from PIL import ImageGrab
im = ImageGrab.grabclipboard() # None if the clipboard does not contain image
im.save('somefile.png','PNG')
Convert an image to bytes howto
- Though
Image.tobytes()
exists, it returns the internal representation of the image. - As we generally need to bytes in common formats like
png
, we need to useio.BytesIO
andImage.save()
instead.