File size: 335 Bytes
7a38b33
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import base64


def get_image_data(image_path):
    with open(image_path, "rb") as f:
        image_data = base64.b64encode(f.read()).decode("utf-8")
    return image_data


def get_data_format(image_path):
    image_format = image_path.split(".")[-1]
    if image_format == "jpg":
        image_format = "jpeg"
    return image_format