Real-image posters: scale to the box's pixel size

Ghostty shows an image smaller than its placement at its own size, so
library posters (Radarr's poster-500 is 333x500, not 500x750) came out
smaller than the 426x640 remote ones. Images are now scaled (bilinear)
to exactly cols*cellWidth x rows*cellHeight pixels before upload, and
library titles use the original poster for real images. The disk cache
stores posters as decoded (JPEG) instead of the possibly large originals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 11:25:45 +02:00
co-authored by Claude Opus 5.5
parent 786e783951
commit 15e97f4582
8 changed files with 100 additions and 25 deletions
+24
View File
@@ -393,3 +393,27 @@ func TestGraphicsNeedTheTerminalsConfirmation(t *testing.T) {
t.Error("a known terminal that answers gets real images")
}
}
func TestPostersAreSentAtTheBoxSize(t *testing.T) {
img := image.NewRGBA(image.Rect(0, 0, 333, 500)) // Radarr's "500" copy, smaller than the box
var msgs []string
k := newKittyGraphics(func([]byte) error { return nil })
k.debug = func(m string) { msgs = append(msgs, m) }
k.cellPixels = func() (int, int) { return 22, 48 } // a high-resolution screen
if _, err := k.show(img, img.Bounds(), 31, 21); err != nil {
t.Fatal(err)
}
if len(msgs) != 1 || !strings.Contains(msgs[0], "sent as 682x1008 px") {
t.Errorf("upload: %q", msgs)
}
// Without the cell size the image goes as it is.
k.cellPixels = func() (int, int) { return 0, 0 }
img2 := image.NewRGBA(image.Rect(0, 0, 426, 640))
msgs = nil
if _, err := k.show(img2, img2.Bounds(), 31, 21); err != nil {
t.Fatal(err)
}
if len(msgs) != 1 || !strings.Contains(msgs[0], "sent as 426x640 px") {
t.Errorf("upload without cell size: %q", msgs)
}
}