mirror of
https://github.com/microsoft/OmniParser.git
synced 2025-02-18 03:18:33 +03:00
13 lines
396 B
Python
13 lines
396 B
Python
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") |