MCPcopy
hub / github.com/langchain-ai/langchain / encode_image

Function encode_image

libs/core/langchain_core/utils/image.py:5–8  ·  view source on GitHub ↗

Get base64 string from image URI.

(image_path: str)

Source from the content-addressed store, hash-verified

3
4
5def encode_image(image_path: str) -> str:
6 """Get base64 string from image URI."""
7 with open(image_path, "rb") as image_file:
8 return base64.b64encode(image_file.read()).decode("utf-8")
9
10
11def image_to_data_url(image_path: str) -> str:

Callers 1

image_to_data_urlFunction · 0.85

Calls 1

readMethod · 0.45

Tested by

no test coverage detected