1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

fix(icon): improve logging messages in resizeIcon function

This commit is contained in:
Frédéric Guillot 2025-08-19 19:58:42 -07:00
parent 1b1ceaf8b4
commit fdc12bf18c

View file

@ -203,13 +203,13 @@ func resizeIcon(icon *model.Icon) *model.Icon {
// minifier.Bytes returns the data unchanged in case of error.
icon.Content, err = minifier.Bytes("image/svg+xml", icon.Content)
if err != nil {
slog.Error("Unable to minimize the svg file", slog.Any("error", err))
slog.Error("Unable to minify SVG icon", slog.Any("error", err))
}
return icon
}
if !slices.Contains([]string{"image/jpeg", "image/png", "image/gif", "image/webp"}, icon.MimeType) {
slog.Info("icon isn't a png/gif/jpeg/webp, can't resize", slog.String("mimetype", icon.MimeType))
slog.Info("Icon resize skipped: unsupported MIME type", slog.String("mime_type", icon.MimeType))
return icon
}
@ -218,11 +218,11 @@ func resizeIcon(icon *model.Icon) *model.Icon {
// Don't resize icons that we can't decode, or that already have the right size.
config, _, err := image.DecodeConfig(r)
if err != nil {
slog.Warn("unable to decode the metadata of the icon", slog.Any("error", err))
slog.Warn("Unable to decode icon metadata", slog.Any("error", err))
return icon
}
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))
slog.Debug("Icon doesn't need to be resized", slog.Int("height", config.Height), slog.Int("width", config.Width))
return icon
}
@ -240,7 +240,7 @@ func resizeIcon(icon *model.Icon) *model.Icon {
src, err = webp.Decode(r)
}
if err != nil || src == nil {
slog.Warn("unable to decode the icon", slog.Any("error", err))
slog.Warn("Unable to decode icon image", slog.Any("error", err))
return icon
}
@ -249,7 +249,8 @@ func resizeIcon(icon *model.Icon) *model.Icon {
var b bytes.Buffer
if err = png.Encode(io.Writer(&b), dst); err != nil {
slog.Warn("unable to encode the new icon", slog.Any("error", err))
slog.Warn("Unable to encode resized icon", slog.Any("error", err))
return icon
}
icon.Content = b.Bytes()