zot/go.mod
patriceckhart ef7327ca7d anthropic: downscale oversized images on outbound requests
Anthropic returns 'At least one of the image dimensions exceed max
allowed size for many-image requests' when a request contains more
than one image and any of them is larger than 2000 px on the
longest side. Single-image requests get a more lenient 8000 px
cap. OpenAI has no such limit, so a session that worked fine on
gpt-* breaks the moment /model swaps to a Claude family while the
transcript still holds high-res screenshots.

Add anthShrinkImageBytesIfTooBig that decodes any outbound image
exceeding 2000 px on the longest side, resamples it with Catmull-
Rom from golang.org/x/image/draw, and re-encodes in the same
format. JPEG stays JPEG, PNG stays PNG, GIF gets re-encoded as
PNG (we'd otherwise need to compose a single-frame gif by hand).
Decode/encode failures fall back to the original bytes so the
caller's flow is untouched and Anthropic's own error message
surfaces if the image is genuinely unusable.

Both Anthropic encode sites \u2014 the top-level message converter
and the tool-result inner converter \u2014 run every image through
the helper, so screenshots from earlier turns also get resized
on subsequent requests instead of failing forever once the
transcript captured them at full size.

Adds golang.org/x/image v0.18.0 (compatible with go 1.22).
2026-04-28 12:48:13 +02:00

17 lines
366 B
Modula-2

module github.com/patriceckhart/zot
go 1.22
require (
github.com/alecthomas/chroma/v2 v2.23.1
github.com/google/uuid v1.6.0
github.com/mattn/go-runewidth v0.0.16
golang.org/x/sys v0.26.0
golang.org/x/term v0.25.0
)
require (
github.com/dlclark/regexp2 v1.11.5 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
golang.org/x/image v0.18.0 // indirect
)