pyrit.common.convert_local_image_to_data_url

pyrit.common.convert_local_image_to_data_url#

async convert_local_image_to_data_url(image_path: str) str[source]#

Converts a local image file to a data URL encoded in base64.

Parameters:

image_path (str) – The file system path to the image file.

Raises:
  • FileNotFoundError – If no file is found at the specified image_path.

  • ValueError – If the image file’s extension is not in the supported formats list.

Returns:

A string containing the MIME type and the base64-encoded data of the image, formatted as a data URL.

Return type:

str