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:bytesdecoded, turned upright by their EXIF orientation and encoded as PNG.Nonewhen 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.Nonewhen nothing changed. - process
- pi’s
processImage: an image that is not PNG, JPEG, GIF or WebP becomes PNG when theimagecrate, with Photon’s formats, recognizes it from its bytes (BMP, TIFF, ICO, PNM, HDR, DDS or farbfeld), and withauto_resizethe image is fitted tolimits, 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 withinlimits, 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.Nonewhen the image does not decode or no encoding fits. - to_png
- The clipboard’s
convertToPng:bytesdecoded to RGBA and encoded as PNG, with no EXIF orientation and no resizing.Nonewhen they do not decode.