Spaces:
Running
Running
| import base64 | |
| def to_base64_bytes(data: bytes) -> str: | |
| return base64.b64encode(data).decode("utf-8") | |
| def file_to_base64(path: str) -> str: | |
| with open(path, "rb") as f: | |
| return to_base64_bytes(f.read()) | |
| def is_image_name(name: str) -> bool: | |
| return name.lower().endswith((".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp")) | |