I'm receiving a buffer from somewhere that contains an image (image_data
below), and I'd like to generate a thumbnail from that buffer.
I was thinking to use PIL (well, Pillow), but no success. Here's what I've tried:
>>> image_data
<read-only buffer for 0x03771070, size 3849, offset 0 at 0x0376A900>
>>> im = Image.open(image_data)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "<path>\PIL\Image.py", line 2097, in open
prefix = fp.read(16)
AttributeError: 'buffer' object has no attribute 'read'
>>> image_data.thumbnail(50, 50)
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'buffer' object has no attribute 'thumbnail'
>>>
I'm sure there is an easy way to fix this, but I'm not sure how.