MingDoan's picture
feat: Big Update
3a63794
raw
history blame contribute delete
292 Bytes
import io
from PIL import Image
# Convert image to bytes
def image_to_bytes(image: Image):
img_byte_arr = io.BytesIO()
image.save(img_byte_arr, format='PNG')
return img_byte_arr.getvalue()
def bytes_to_image(image_bytes: bytes):
return Image.open(io.BytesIO(image_bytes))