I saved a picture into mongodb as binary file, but when I read it and use pillow to load this picture, It's not the picture I want. here is my code
from pymongo import MongoClient
from PIL import Image
client = MongoClient('', 27017)
db = client.mytest [enter image description here][1]
my_set = db.test_set
def save_pic():
with open(r'C:\Users\Administrator\Desktop\照片\wallhaven-634613.jpg',
'rb') as f:
data = f.read()
my_set.insert({"pic":data})
def read_pic():
data = my_set.find({"id": "dk"})[0]
Image.frombytes("RGB", (100,100), data["pic"]).show()
read_pic()
image is under here