MCPcopy Index your code
hub / github.com/InternScience/SpectrumLab / encode_image_to_base64

Function encode_image_to_base64

spectrumlab/utils/image_utils.py:6–11  ·  view source on GitHub ↗
(image_path: str)

Source from the content-addressed store, hash-verified

4
5
6def encode_image_to_base64(image_path: str) -> str:
7 try:
8 with open(image_path, "rb") as image_file:
9 return base64.b64encode(image_file.read()).decode("utf-8")
10 except Exception as e:
11 raise ValueError(f"Failed to encode image to base64: {e}")
12
13
14def get_image_mime_type(image_path: str) -> str:

Calls

no outgoing calls