mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-06 10:23:21 +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 {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
buf := new(bytes.Buffer)
|
||||||
err = jpeg.Encode(buf, m, &jpeg.Options{Quality: conf.Server.CoverJpegQuality})
|
err = jpeg.Encode(buf, m, &jpeg.Options{Quality: conf.Server.CoverJpegQuality})
|
||||||
return buf.Bytes(), err
|
return buf.Bytes(), err
|
||||||
|
@ -77,6 +77,7 @@ const useCoverStyles = makeStyles({
|
|||||||
cover: {
|
cover: {
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
'object-fit': 'contain',
|
||||||
height: (props) => props.height,
|
height: (props) => props.height,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user