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

Function encode_image_to_base64

RealChart2Code_eval/evaluate_task1.py:518–526  ·  view source on GitHub ↗
(image_path: Path)

Source from the content-addressed store, hash-verified

516 return buffer.getvalue()
517
518def encode_image_to_base64(image_path: Path) -> str:
519
520 image_data = compress_image_if_needed(image_path)
521 encoded_string = base64.b64encode(image_data).decode('utf-8')
522
523 if image_data.startswith(b'\xff\xd8\xff'):
524 return f"data:image/jpeg;base64,{encoded_string}"
525 else:
526 return f"data:image/png;base64,{encoded_string}"
527
528
529def create_evaluation_request(difficulty: str, category: str, instruction: str, image_path:Path,

Callers 3

run_benchmarkFunction · 0.70

Calls 1

compress_image_if_neededFunction · 0.70

Tested by

no test coverage detected