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:
parent
1b1ceaf8b4
commit
fdc12bf18c
1 changed files with 7 additions and 6 deletions
|
@ -203,13 +203,13 @@ func resizeIcon(icon *model.Icon) *model.Icon {
|
||||||
// minifier.Bytes returns the data unchanged in case of error.
|
// minifier.Bytes returns the data unchanged in case of error.
|
||||||
icon.Content, err = minifier.Bytes("image/svg+xml", icon.Content)
|
icon.Content, err = minifier.Bytes("image/svg+xml", icon.Content)
|
||||||
if err != nil {
|
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
|
return icon
|
||||||
}
|
}
|
||||||
|
|
||||||
if !slices.Contains([]string{"image/jpeg", "image/png", "image/gif", "image/webp"}, icon.MimeType) {
|
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
|
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.
|
// Don't resize icons that we can't decode, or that already have the right size.
|
||||||
config, _, err := image.DecodeConfig(r)
|
config, _, err := image.DecodeConfig(r)
|
||||||
if err != nil {
|
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
|
return icon
|
||||||
}
|
}
|
||||||
if config.Height <= 32 && config.Width <= 32 {
|
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
|
return icon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ func resizeIcon(icon *model.Icon) *model.Icon {
|
||||||
src, err = webp.Decode(r)
|
src, err = webp.Decode(r)
|
||||||
}
|
}
|
||||||
if err != nil || src == nil {
|
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
|
return icon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,8 @@ func resizeIcon(icon *model.Icon) *model.Icon {
|
||||||
|
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
if err = png.Encode(io.Writer(&b), dst); err != nil {
|
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()
|
icon.Content = b.Bytes()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue