Skip to main content

Module image

Module image 

Source
Expand description

Image processing utilities

Structs§

ImageData
Represents the data from an image file ready for LLM consumption

Constants§

MAX_IMAGE_FILE_BYTES
Maximum accepted image file size (20 MB).
SUPPORTED_IMAGE_EXTENSIONS
File extensions that map to SUPPORTED_IMAGE_MIME_TYPES.
SUPPORTED_IMAGE_MIME_TYPES
Image MIME types accepted by LLM vision APIs.
UNSUPPORTED_BINARY_IMAGE_EXTENSIONS
Binary raster extensions no LLM vision API accepts.

Functions§

detect_mime_type_from_content_type
Detects MIME type from Content-Type header.
detect_mime_type_from_data
Detects MIME type from file data (magic bytes)
encode_to_base64
Encodes binary data to base64
has_supported_image_extension
Validates that the image file path has a provider-supported extension.
is_supported_image_mime_type
Returns whether a MIME type can be sent to LLM vision APIs.
read_image_file
Reads an image file from the local filesystem and converts it to base64 format.
read_image_file_any_path
Reads an image file from an absolute path (or already validated path) and converts it to base64.