Skip to main content

Module image

Module image 

Source
Expand description

The item image shape every model-batch role shares, its validation, and its canonical form.

An image is a data: URL string or {content_type, base64}. Remote URLs are never accepted. Validation decodes the base64, so an image a module admits is one the provider can read, and sizes are the decoded bytes. The canonical form, {content_type, base64} with the decoded bytes re-encoded as standard padded base64, is what batch identity hashes: one image sent in either spelling is the same batch (RULES.md §2, §13).

Modules§

content_types
Image content types a provider accepts.

Structs§

DecodedImage
An image’s content type and decoded bytes.
ImageLimits
A model’s image limits per item, as an extractor role.describe entry states them: {max, max_bytes_each, max_bytes_total, formats}.
InlineImage
An image in its object form: {content_type, base64}.

Enums§

Image
An image: a data: URL string, or {content_type, base64}. Remote URLs are never accepted.

Constants§

IMAGES_MAX_TOTAL_BYTES
Largest total of an item’s images, in decoded bytes (8 MiB).
IMAGE_MAX_BYTES
Largest image, in decoded bytes (4 MiB), as Cloudflare Workers AI states it for its image-taking batch models.
IMAGE_MAX_PIXELS
Largest image, in pixels (16 megapixels). The role crates do not decode image formats, so this is a runner’s check, not check_image’s.

Functions§

check_image
Check one image against Workers AI’s limits (ImageLimits::workers_ai).
check_image_with
Check one image’s form, content type, base64 and decoded size against limits, returning its decoded size. The error says why it is refused.
check_images
Check an item’s images: their count against limits.max (None when the model takes no images), each image (check_image_with), and their decoded total. field is the item’s images path (items[i].images); a refusal names it, or field[j] for one image.