utils.py 187 B

123456
  1. import base64
  2. def image_to_base(image_path):
  3. with open(image_path, 'rb') as image_file:
  4. image_base = base64.b64encode(image_file.read()).decode('utf-8')
  5. return image_base