mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-17 04:22:23 +03:00
Fix aspect ratio for non-square album art.
This commit is contained in:
parent
3996764486
commit
69b2fe92f5
@ -171,7 +171,16 @@ func resizeImage(reader io.Reader, size int) ([]byte, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m := imaging.Resize(img, size, size, imaging.Lanczos)
|
||||
|
||||
// Preserve the aspect ratio of the image.
|
||||
var m *image.NRGBA
|
||||
bounds := img.Bounds()
|
||||
if bounds.Max.X > bounds.Max.Y {
|
||||
m = imaging.Resize(img, size, 0, imaging.Lanczos)
|
||||
} else {
|
||||
m = imaging.Resize(img, 0, size, imaging.Lanczos)
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
err = jpeg.Encode(buf, m, &jpeg.Options{Quality: conf.Server.CoverJpegQuality})
|
||||
return buf.Bytes(), err
|
||||
|
@ -77,6 +77,7 @@ const useCoverStyles = makeStyles({
|
||||
cover: {
|
||||
display: 'inline-block',
|
||||
width: '100%',
|
||||
'object-fit': 'contain',
|
||||
height: (props) => props.height,
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user