Skip to main content

Module images

Module images 

Source
Expand description

pi’s image pipeline: what an image becomes before it enters the conversation. Formats models do not accept become PNG, and with images.autoResize images are fitted to the model’s limits.

Structs§

Processed
An image ready for the model, with pi’s notes on how it changed.
Resized
pi’s ResizedImage: an image fitted to the limits, with its dimensions before and after.

Functions§

convert_to_png
pi’s convertImageBytesToPng: bytes decoded, turned upright by their EXIF orientation and encoded as PNG. None when they do not decode.
normalize_prompt
pi’s _normalizePromptImages: a prompt’s images processed for the model, with pi’s notes, which include the omission note of each image that fails.
normalize_tool_result
pi’s normalizeToolResultImages: each image of a tool result processed as for the model, followed by a text block of pi’s notes when there are any. An image that fails keeps its block. None when nothing changed.
process
pi’s processImage: an image that is not PNG, JPEG, GIF or WebP becomes PNG when the image crate, with Photon’s formats, recognizes it from its bytes (BMP, TIFF, ICO, PNM, HDR, DDS or farbfeld), and with auto_resize the image is fitted to limits, pi’s defaults where unset: 2000×2000 and 4.5 MB of base64. The error is pi’s omission note.
resize_image
pi’s resizeImage: the image unchanged when it is within limits, pi’s defaults where unset (2000×2000 and 4.5 MB of base64). Otherwise the image scaled to fit, as the first of PNG and JPEG at falling qualities that fits the byte limit, shrinking by a quarter until one does. None when the image does not decode or no encoding fits.
to_png
The clipboard’s convertToPng: bytes decoded to RGBA and encoded as PNG, with no EXIF orientation and no resizing. None when they do not decode.