AdGenesis-App / util /image_utils.py
userIdc2024's picture
Upload 41 files
9bc1376 verified
raw
history blame contribute delete
342 Bytes
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"))