diff --git a/consts/consts.go b/consts/consts.go index 6fb6c5da..f1010a87 100644 --- a/consts/consts.go +++ b/consts/consts.go @@ -70,8 +70,6 @@ const ( PlaceholderArtistArt = "artist-placeholder.webp" PlaceholderAlbumArt = "album-placeholder.webp" PlaceholderAvatar = "logo-192x192.png" - UICoverArtSize = 300 - UIThumbnailSize = 80 DefaultUIVolume = 100 DefaultUISearchDebounceMs = 200 @@ -86,6 +84,12 @@ const ( Zwsp = string('\u200b') ) +const ( + UICoverArtSize = 600 +) + +var CacheWarmerImageSizes = []int{UICoverArtSize} + // Prometheus options const ( PrometheusDefaultPath = "/metrics" diff --git a/core/artwork/cache_warmer.go b/core/artwork/cache_warmer.go index 83c98c80..bd1359b7 100644 --- a/core/artwork/cache_warmer.go +++ b/core/artwork/cache_warmer.go @@ -142,15 +142,14 @@ func (a *cacheWarmer) doCacheImage(ctx context.Context, id model.ArtworkID) erro ctx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - for _, size := range []int{consts.UICoverArtSize, consts.UIThumbnailSize} { + for _, size := range consts.CacheWarmerImageSizes { r, _, err := a.artwork.Get(ctx, id, size, true) if err != nil { return fmt.Errorf("caching id='%s', size=%d: %w", id, size, err) } - defer r.Close() - if _, err = io.Copy(io.Discard, r); err != nil { - return err - } + _, err = io.Copy(io.Discard, r) + r.Close() + return err } return nil } diff --git a/core/artwork/cache_warmer_test.go b/core/artwork/cache_warmer_test.go index 6ddda00d..9798ea8d 100644 --- a/core/artwork/cache_warmer_test.go +++ b/core/artwork/cache_warmer_test.go @@ -176,13 +176,13 @@ var _ = Describe("CacheWarmer", func() { }).Should(Equal(0)) }) - It("pre-caches both UICoverArtSize and UIThumbnailSize", func() { + It("pre-caches UICoverArtSize", func() { cw := NewCacheWarmer(aw, fc).(*cacheWarmer) cw.PreCache(model.MustParseArtworkID("al-1")) Eventually(func() []int { return aw.getCachedSizes() - }).Should(ContainElements(consts.UICoverArtSize, consts.UIThumbnailSize)) + }).Should(ContainElements(consts.UICoverArtSize)) }) }) }) diff --git a/core/artwork/reader_playlist.go b/core/artwork/reader_playlist.go index 7919eead..09707843 100644 --- a/core/artwork/reader_playlist.go +++ b/core/artwork/reader_playlist.go @@ -264,6 +264,6 @@ func fillCenter(src image.Image, dstW, dstH int) image.Image { } dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH)) - xdraw.BiLinear.Scale(dst, dst.Bounds(), src, cropRect, draw.Src, nil) + xdraw.CatmullRom.Scale(dst, dst.Bounds(), src, cropRect, draw.Src, nil) return dst } diff --git a/core/artwork/reader_resized.go b/core/artwork/reader_resized.go index 7e90f10e..72baad43 100644 --- a/core/artwork/reader_resized.go +++ b/core/artwork/reader_resized.go @@ -155,7 +155,7 @@ func resizeStaticImage(data []byte, size int, square bool) (io.Reader, int, erro dst = image.NewNRGBA(image.Rect(0, 0, dstW, dstH)) dstRect = dst.Bounds() } - xdraw.BiLinear.Scale(dst, dstRect, original, bounds, draw.Src, nil) + xdraw.CatmullRom.Scale(dst, dstRect, original, bounds, draw.Src, nil) buf := bufPool.Get().(*bytes.Buffer) buf.Reset() diff --git a/ui/src/album/AlbumDetails.jsx b/ui/src/album/AlbumDetails.jsx index c5d9a7ac..2411b861 100644 --- a/ui/src/album/AlbumDetails.jsx +++ b/ui/src/album/AlbumDetails.jsx @@ -18,6 +18,7 @@ import { useTranslate, } from 'react-admin' import Lightbox from 'react-image-lightbox' +import { COVER_ART_SIZE } from '../consts' import 'react-image-lightbox/style.css' import subsonic from '../subsonic' import { @@ -254,7 +255,7 @@ const AlbumDetails = (props) => { }) }, [record]) - const imageUrl = subsonic.getCoverArtUrl(record, 300) + const imageUrl = subsonic.getCoverArtUrl(record, COVER_ART_SIZE) const fullImageUrl = subsonic.getCoverArtUrl(record) return ( diff --git a/ui/src/album/AlbumGridView.jsx b/ui/src/album/AlbumGridView.jsx index 6b44c5fe..e90e7a77 100644 --- a/ui/src/album/AlbumGridView.jsx +++ b/ui/src/album/AlbumGridView.jsx @@ -19,7 +19,7 @@ import { ArtistLinkField, OverflowTooltip, } from '../common' -import { DraggableTypes } from '../consts' +import { COVER_ART_SIZE, DraggableTypes } from '../consts' import clsx from 'clsx' import { AlbumDatesField } from './AlbumDatesField.jsx' @@ -157,7 +157,7 @@ const Cover = withContentRect('bounds')(({