From 7161a90708ae42e442848498b6a01b508cb03571 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 16 Dec 2024 22:53:38 +0100 Subject: [PATCH] Resize favicons to 32x32 to account of scaling As suggested by @michaelkuhn in https://github.com/miniflux/v2/pull/2998#issuecomment-2546702212 --- internal/reader/icon/finder.go | 4 ++-- internal/reader/icon/finder_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/reader/icon/finder.go b/internal/reader/icon/finder.go index e0efc90bd2e..21d179bb236 100644 --- a/internal/reader/icon/finder.go +++ b/internal/reader/icon/finder.go @@ -206,7 +206,7 @@ func resizeIcon(icon *model.Icon) *model.Icon { slog.Warn("unable to decode the metadata of the icon", slog.Any("error", err)) return icon } - if config.Height <= 16 && config.Width <= 16 { + if config.Height <= 32 && config.Width <= 32 { slog.Debug("icon don't need to be rescaled", slog.Int("height", config.Height), slog.Int("width", config.Width)) return icon } @@ -227,7 +227,7 @@ func resizeIcon(icon *model.Icon) *model.Icon { return icon } - dst := image.NewRGBA(image.Rect(0, 0, 16, 16)) + dst := image.NewRGBA(image.Rect(0, 0, 32, 32)) draw.BiLinear.Scale(dst, dst.Rect, src, src.Bounds(), draw.Over, nil) var b bytes.Buffer diff --git a/internal/reader/icon/finder_test.go b/internal/reader/icon/finder_test.go index 1cd632afe7f..3a06e35f5dd 100644 --- a/internal/reader/icon/finder_test.go +++ b/internal/reader/icon/finder_test.go @@ -146,7 +146,7 @@ func TestResizeIconSmallGif(t *testing.T) { } func TestResizeIconPng(t *testing.T) { - data, err := base64.StdEncoding.DecodeString("iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAHElEQVR42mP8z/C/noFCwDhqyKgho4aMGkIlQwBrHSpf28Yx+gAAAABJRU5ErkJggg==") + data, err := base64.StdEncoding.DecodeString("iVBORw0KGgoAAAANSUhEUgAAACEAAAAhCAYAAABX5MJvAAAALUlEQVR42u3OMQEAAAgDoJnc6BpjDyRgcrcpGwkJCQkJCQkJCQkJCQkJCYmyB7NfUj/Kk4FkAAAAAElFTkSuQmCC") if err != nil { t.Fatal(err) } @@ -157,7 +157,7 @@ func TestResizeIconPng(t *testing.T) { resizedIcon := resizeIcon(&icon) if bytes.Equal(data, resizedIcon.Content) { - t.Fatalf("Didn't convert png of 17x17") + t.Fatalf("Didn't convert png of 33x33") } config, _, err := image.DecodeConfig(bytes.NewReader(resizedIcon.Content)) @@ -165,7 +165,7 @@ func TestResizeIconPng(t *testing.T) { t.Fatalf("Couln't decode resulting png: %v", err) } - if config.Height != 16 || config.Width != 16 { + if config.Height != 32 || config.Width != 32 { t.Fatalf("Was expecting an image of 16x16, got %dx%d", config.Width, config.Height) } }