Documentation
¶
Overview ¶
Package imageutil holds shared image transforms for the model-bound image path. The one transform today is Downscale: cap an image's longest edge before it is inlined as a data_uri, so a full-resolution screenshot/PDF-page render doesn't cost full vision tokens on every provider call. It operates ONLY on the copy sent to the model — the on-disk materialized blob stays full resolution for the file tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Downscale ¶
Downscale returns image bytes whose longest edge is <= maxEdge, re-encoded as PNG (lossless — preserves text/screenshots without artifacts). It is a best-effort no-op that returns the ORIGINAL bytes with resized=false when:
- maxEdge <= 0 (feature off) or data is empty,
- the bytes aren't a decodable image,
- the image already fits within maxEdge, or
- decode/scale/encode fails.
On a successful resize it returns the new bytes, mime "image/png", and true. The PNG byte size may exceed the source for a downscaled photo, but that doesn't matter for vision tokens (the model rasterizes by pixels, and the caller's byte-size caps still apply); reducing PIXELS is what cuts the token cost.
Types ¶
This section is empty.