I have the following code that creates a thumbnail from a request to a url:
r = requests.get(image_url, stream=True, headers=headers)
size = 500, 500
img = Image.open(r.raw)
thumb = ImageOps.fit(img, size, Image.ANTIALIAS)
At this point I would like to store the image inside a mongo document like so:
photo = {
'thumbnail': img,
'source': source,
'tags': tags,
'creationDate': datetime.now(),
}
Obviously that won't work so what kind of transformation do I need to apply before I can do this?