db['images'].remove()
db['images'].insert({'id': 1, 'img': Binary(data)})
for rec in db['images'].find():
    im = Image.open(StringIO(rec['img']))
im.show()
Display image of PNG binary that is stored in MongoDB