Spaces:
Runtime error
Runtime error
File size: 292 Bytes
3a63794 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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))
|