Spaces:
Running
Running
File size: 325 Bytes
cdd56aa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import base64
from io import BytesIO
# pip3 install pillow
from PIL import Image
import re
def base64_to_image(base64_str):
base64_data = re.sub('^data:image/.+;base64,', '', base64_str)
byte_data = base64.b64decode(base64_data)
image_data = BytesIO(byte_data)
img = Image.open(image_data)
return img
|