Image handling utilities for multimodal models.
Provides automatic loading and Base64 encoding of images from:
- File paths
- Binary data
- Already-encoded Base64 strings
- URLs (download and encode)
Summary
Functions
Encode an image to Base64.
Encode an image, raising on error.
Encode multiple images.
Encode multiple images, raising on error.
Load and encode an image from a URL.
Types
Functions
@spec encode(image_input()) :: {:ok, encoded_image()} | {:error, term()}
Encode an image to Base64.
@spec encode!(image_input()) :: encoded_image()
Encode an image, raising on error.
@spec encode_all([image_input()]) :: {:ok, [encoded_image()]} | {:error, term()}
Encode multiple images.
Returns {:ok, list} if all succeed, {:error, reason} on first failure.
@spec encode_all!([image_input()]) :: [encoded_image()]
Encode multiple images, raising on error.
@spec from_url( String.t(), keyword() ) :: {:ok, encoded_image()} | {:error, term()}
Load and encode an image from a URL.
Options
:timeout- Request timeout in ms (default: 30_000):max_size- Maximum file size in bytes (default: 20MB)