MCPcopy Create free account
hub / github.com/Speakn0w/RealChart2Code / encode_image_to_base64

Function encode_image_to_base64

RealChart2Code_eval/evaluate_task2.py:512–520  ·  view source on GitHub ↗
(image_path: Path)

Source from the content-addressed store, hash-verified

510
511
512def encode_image_to_base64(image_path: Path) -> str:
513
514 image_data = compress_image_if_needed(image_path)
515 encoded_string = base64.b64encode(image_data).decode('utf-8')
516
517 if image_data.startswith(b'\xff\xd8\xff'):
518 return f"data:image/jpeg;base64,{encoded_string}"
519 else:
520 return f"data:image/png;base64,{encoded_string}"
521
522
523def create_evaluation_request(difficulty: str, category: str, data_info: str, image_path:str,

Callers 3

run_benchmarkFunction · 0.70

Calls 1

compress_image_if_neededFunction · 0.70

Tested by

no test coverage detected