image
A picture, such as a photo, a scan or a screenshot. The text in it is read for you, and a model looks at the picture itself.
At a glance
- Stored as: a handle (
image-…), kept once by its content and referred to by that handle. - Read in parts: by a range of lines.
- Media formats:
png,jpeg. - Edited by: filling its fields and drawing on it.
- Form fields: its fillable fields can be found and filled.
- Search: by passage, so full-text and similarity search rank a value by its best passage.
Writing
- Send the picture: upload it, or give create its
file, its bytes, an http(s) URL or adata:URI. JPEG, PNG, GIF, BMP, WebP, TIFF and HEIC are read. A one-page PDF becomes a picture of its page; a longer PDF is refused (store it as a pdf). - Every picture is stored as a JPEG: transparency is lost, and an animation keeps only its first frame.
- To generate a picture from a description, call create with
opts{"kind": "generate"}and the description assource. Generation is a paid model call.
Written as
A JSON object.
__dtype__: str
Create options
Options for generating an image from a description.
kind: optional "generate". Selects image generation; source is the prompt.model: optional str. Image model.quality: optional "low" or "medium" or "high" or "hd" or "standard" or 1 more. Rendering quality.size: optional str. Width x height in pixels.
Reading
- get_content reads the text in the picture:
rangecounts its lines from 1, andquerysearches them. The text is read the first time anyone asks for it, or by the search index shortly after the picture is saved. - get_media returns the picture itself, as
pngorjpeg, or as stored whenformatis left out. A picture is shown whole:rangeis ignored.
Querying
A picture is found two ways (see the HQL reference): by the text
read from it, with ~* and ~~, once that text has been read, a little after the save;
and by what it shows, with ~=, which compares your words with the picture itself. For a
picture hit, match.hash is the picture's own handle, and match.text holds that handle
too, not the read text.
Message | ~= "a photo of a damaged parcel" | match.dtype = "image" | select id, match.hash, match.score | limit 10
Message | content ~* "invoice number" | match.dtype = "image" | select id, match.hash | limit 20
content.dtype asks whether a message carries a picture at all, without searching:
Message | content.dtype = "image" AND created_at >= NOW() - INTERVAL '7 days' | select id, created_at
Editing
- extract_form_fields finds the fields of a form in the picture by reading it (a paid call). Each has a stable id and its box as fractions (0 to 1) of the picture; all are on page 1.
- edit with
filledits writes a value at the top left of a field's box by its id;truemarks a checkbox with an X.drawedits add text, a picture (its handle) or SVG in a box[x, y, w, h], fractions of the picture measured from its top left;pageis ignored. - Edits are painted into the pixels in a small plain font, so they cannot be changed afterwards. The result is a new picture under a new handle; the original is unchanged. An edit that cannot be applied is listed as skipped and the others are applied.
In agent tools
- Pass the handle or its
<attachment id="…"/>marker. A generic file whose content is a picture is accepted too. - In a conversation the agent sees the picture itself next to its marker, not only its text. Over MCP and the command line it also gets the read text and a link.
Metadata
Derived values kept with a stored value:
ocr: The text read from the image, one line per line of text. Read the first time the text is asked for, or by the search index shortly after the image is stored.form_fields: Form fields kept with the image, each with itskey(label),value,checkboxstate and positions. Present only when given with the image: extracting form fields returns them without keeping them here.image_header: Facts about the picture:widthandheightin pixels,format(such aspngorjpeg) andsizein bytes. Worked out the first time it is read.thumbnail_jpeg: A small JPEG of the image, 240 pixels on its longer side, base64-encoded. Made the first time a preview needs it.
Operations
Through the dtypes resource: