get_image_data

get_image_data(image_file: str | ForwardRef('Image'), use_b64=True) -> bytes

Loads an image and returns its data either as raw bytes or in base64-encoded format.
This function first loads an image from the specified file, URL, or base64 string using the get_pil_image function. It then saves this image in memory in PNG format and retrieves its binary content. Depending on the use_b64 flag, this binary content is either returned directly or as a base64-encoded string.
Parameters:
image_file (str, or Image): The path to the image file, a URL to an image, or a base64-encoded string of the image.
use_b64 (bool): If True, the function returns a base64-encoded string of the image data.
If False, it returns the raw byte data of the image. Defaults to True.
Returns:
bytes: The image data in raw bytes if use_b64 is False, or a base64-encoded string if use_b64 is True.

Parameters:
NameDescription
image_fileType: str | ForwardRef(‘Image.Image’)
use_b64=True
Returns:
TypeDescription
bytesbytes: The image data in raw bytes if use_b64 is False, or a base64-encoded string if use_b64 is True.