MCPcopy Create free account
hub / github.com/microsoft/Webwright / image_part_from_path

Function image_part_from_path

src/webwright/models/base.py:143–150  ·  view source on GitHub ↗
(path: Path)

Source from the content-addressed store, hash-verified

141
142
143def image_part_from_path(path: Path) -> dict[str, Any]:
144 mime_type, _ = mimetypes.guess_type(str(path))
145 encoded = base64.b64encode(path.read_bytes()).decode("ascii")
146 return {
147 "type": "input_image",
148 "image_url": f"data:{mime_type or 'image/png'};base64,{encoded}",
149 "detail": "high",
150 }
151
152
153def _safe_int(value: Any) -> int:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected