screenshot-to-code/backend/eval_utils.py
2023-12-13 16:38:26 -05:00

8 lines
228 B
Python

import base64
async def image_to_data_url(filepath: str):
with open(filepath, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode()
return f"data:image/png;base64,{encoded_string}"