Spaces:
Running
Running
File size: 342 Bytes
9bc1376 |
1 2 3 4 5 6 7 8 9 10 11 12 |
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"))
|