File size: 301 Bytes
d05d972
 
 
 
 
 
 
04b214b
1
2
3
4
5
6
7
8
import base64, os

def encode_image_to_base64(image_path: str) -> str:
    with open(image_path, "rb") as f:
        return base64.b64encode(f.read()).decode("utf-8")

def is_valid_image(file_name: str) -> bool:
    return file_name.lower().endswith((".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp"))