1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Resize favicons to 32x32 to account of scaling

As suggested by @michaelkuhn in https://github.com/miniflux/v2/pull/2998#issuecomment-2546702212
This commit is contained in:
jvoisin 2024-12-16 22:53:38 +01:00 committed by Frédéric Guillot
parent a06657b74d
commit 7939b54341
2 changed files with 5 additions and 5 deletions

View file

@ -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

View file

@ -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)
}
}