This commit is contained in:
Thomas Dhome Casanova (from Dev Box)
2025-01-31 18:37:14 -08:00
parent ed7b34621b
commit e268184f8d
7 changed files with 119 additions and 28 deletions

View File

@@ -0,0 +1,13 @@
import base64
def is_image_path(text):
image_extensions = (".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif")
if text.endswith(image_extensions):
return True
else:
return False
def encode_image(image_path):
"""Encode image file to base64."""
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode("utf-8")