🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
feat(ui): increase cover art size to 600px and use CatmullRom scaling
Deluancb396f3dba30
diff --git a/consts/consts.go b/consts/consts.goindex 6fb6c5dac..f1010a872 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 = 80DefaultUIVolume = 100DefaultUISearchDebounceMs = 200@@ -86,6 +84,12 @@ const (Zwsp = string('\u200b'))+const (+ UICoverArtSize = 600+)++var CacheWarmerImageSizes = []int{UICoverArtSize}+// Prometheus optionsconst (PrometheusDefaultPath = "/metrics"diff --git a/core/artwork/cache_warmer.go b/core/artwork/cache_warmer.goindex 83c98c806..bd1359b74 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) erroctx, 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.goindex 6ddda00d6..9798ea8d6 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.goindex 7919eead6..09707843d 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.goindex 7e90f10e9..72baad434 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, errodst = 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.jsxindex c5d9a7ac4..2411b8611 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.jsxindex 6b44c5fe9..e90e7a77b 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')(({<div ref={dragAlbumRef}><imgkey={record.id} // Force re-render when record changes- src={subsonic.getCoverArtUrl(record, 300, true)}+ src={subsonic.getCoverArtUrl(record, COVER_ART_SIZE, true)}alt={record.name}className={`${classes.cover} ${imageLoading ? classes.coverLoading : ''}`}onLoad={handleImageLoad}diff --git a/ui/src/artist/DesktopArtistDetails.jsx b/ui/src/artist/DesktopArtistDetails.jsxindex 7052b1634..bc2312477 100644--- a/ui/src/artist/DesktopArtistDetails.jsx+++ b/ui/src/artist/DesktopArtistDetails.jsx@@ -15,6 +15,7 @@ import {import Lightbox from 'react-image-lightbox'import ExpandInfoDialog from '../dialogs/ExpandInfoDialog'import AlbumInfo from '../album/AlbumInfo'+import { COVER_ART_SIZE } from '../consts'import subsonic from '../subsonic'import { SafeHTML } from '../common/SafeHTML'@@ -109,7 +110,7 @@ const DesktopArtistDetails = ({ artistInfo, record, biography }) => {<CardMediakey={record.id}component="img"- src={subsonic.getCoverArtUrl(record, 300)}+ src={subsonic.getCoverArtUrl(record, COVER_ART_SIZE)}className={`${classes.cover} ${imageLoading ? classes.coverLoading : ''}`}onClick={handleOpenLightbox}onLoad={handleImageLoad}diff --git a/ui/src/artist/MobileArtistDetails.jsx b/ui/src/artist/MobileArtistDetails.jsxindex 03cc4de8f..9c6cd88ae 100644--- a/ui/src/artist/MobileArtistDetails.jsx+++ b/ui/src/artist/MobileArtistDetails.jsx@@ -11,6 +11,7 @@ import {useImageLoadingState,} from '../common'import Lightbox from 'react-image-lightbox'+import { COVER_ART_SIZE } from '../consts'import subsonic from '../subsonic'import { SafeHTML } from '../common/SafeHTML'@@ -112,7 +113,7 @@ const MobileArtistDetails = ({ artistInfo, biography, record }) => {<CardMediakey={record.id}component="img"- src={subsonic.getCoverArtUrl(record, 300)}+ src={subsonic.getCoverArtUrl(record, COVER_ART_SIZE)}className={`${classes.cover} ${imageLoading ? classes.coverLoading : ''}`}onClick={handleOpenLightbox}onLoad={handleImageLoad}diff --git a/ui/src/common/CoverArtAvatar.jsx b/ui/src/common/CoverArtAvatar.jsxindex 6610cb75e..5642f2504 100644--- a/ui/src/common/CoverArtAvatar.jsx+++ b/ui/src/common/CoverArtAvatar.jsx@@ -2,6 +2,7 @@ import { useRecordContext } from 'react-admin'import { Avatar } from '@material-ui/core'import { makeStyles } from '@material-ui/core/styles'import clsx from 'clsx'+import { COVER_ART_SIZE } from '../consts'import subsonic from '../subsonic'const useStyles = makeStyles({@@ -25,7 +26,7 @@ export const CoverArtAvatar = ({const square = variant !== 'circular'return (<Avatar- src={subsonic.getCoverArtUrl(record, 80, square)}+ src={subsonic.getCoverArtUrl(record, COVER_ART_SIZE, square)}variant={variant}className={clsx(classes.avatar, square && classes.square)}alt={record.name}diff --git a/ui/src/consts.js b/ui/src/consts.jsindex 472cd4940..68ec478f1 100644--- a/ui/src/consts.js+++ b/ui/src/consts.js@@ -26,6 +26,8 @@ DraggableTypes.ALL.push(export const RADIO_PLACEHOLDER_IMAGE = 'internet-radio-icon.svg'+export const COVER_ART_SIZE = 600+export const DEFAULT_SHARE_BITRATE = 128export const BITRATE_CHOICES = [diff --git a/ui/src/playlist/PlaylistDetails.jsx b/ui/src/playlist/PlaylistDetails.jsxindex 911e6c716..f2f528d4b 100644--- a/ui/src/playlist/PlaylistDetails.jsx+++ b/ui/src/playlist/PlaylistDetails.jsx@@ -18,6 +18,7 @@ import {OverflowTooltip,useImageLoadingState,} from '../common'+import { COVER_ART_SIZE } from '../consts'import subsonic from '../subsonic'const useStyles = makeStyles(@@ -106,7 +107,7 @@ const PlaylistDetails = (props) => {handleCloseLightbox,} = useImageLoadingState(record.id)- const imageUrl = subsonic.getCoverArtUrl(record, 300, true)+ const imageUrl = subsonic.getCoverArtUrl(record, COVER_ART_SIZE, true)const fullImageUrl = subsonic.getCoverArtUrl(record)return (diff --git a/ui/src/radio/RadioEdit.jsx b/ui/src/radio/RadioEdit.jsxindex 6b1d2df79..5f804535a 100644--- a/ui/src/radio/RadioEdit.jsx+++ b/ui/src/radio/RadioEdit.jsx@@ -11,7 +11,7 @@ import { makeStyles } from '@material-ui/core/styles'import { urlValidate } from '../utils/validations'import { Title, ImageUploadOverlay, useImageLoadingState } from '../common'import subsonic from '../subsonic'-import { RADIO_PLACEHOLDER_IMAGE } from '../consts'+import { COVER_ART_SIZE, RADIO_PLACEHOLDER_IMAGE } from '../consts'const useStyles = makeStyles({coverParent: {@@ -83,7 +83,7 @@ const RadioCoverArt = ({ record }) => {{record.uploadedImage ? (<CardMediacomponent="img"- src={subsonic.getCoverArtUrl(record, 300, true)}+ src={subsonic.getCoverArtUrl(record, COVER_ART_SIZE, true)}className={`${classes.cover} ${imageLoading ? classes.coverLoading : ''}`}onLoad={handleImageLoad}onError={handleImageError}diff --git a/ui/src/radio/helper.jsx b/ui/src/radio/helper.jsxindex 4c313d3bc..b278c0d7d 100644--- a/ui/src/radio/helper.jsx+++ b/ui/src/radio/helper.jsx@@ -1,5 +1,5 @@import subsonic from '../subsonic'-import { RADIO_PLACEHOLDER_IMAGE } from '../consts'+import { COVER_ART_SIZE, RADIO_PLACEHOLDER_IMAGE } from '../consts'export async function songFromRadio(radio) {if (!radio) {@@ -8,7 +8,7 @@ export async function songFromRadio(radio) {let cover = RADIO_PLACEHOLDER_IMAGEif (radio.uploadedImage) {- cover = subsonic.getCoverArtUrl(radio, 300, true)+ cover = subsonic.getCoverArtUrl(radio, COVER_ART_SIZE, true)} else {// Try favicon as fallbacktry {diff --git a/ui/src/subsonic/index.test.js b/ui/src/subsonic/index.test.jsindex 2544e03f8..38b910b08 100644--- a/ui/src/subsonic/index.test.js+++ b/ui/src/subsonic/index.test.js@@ -1,4 +1,5 @@import { vi } from 'vitest'+import { COVER_ART_SIZE } from '../consts'import subsonic from './index'describe('getCoverArtUrl', () => {@@ -30,10 +31,10 @@ describe('getCoverArtUrl', () => {updatedAt: '2023-01-01T00:00:00Z',}- const url = subsonic.getCoverArtUrl(playlistRecord, 300, true)+ const url = subsonic.getCoverArtUrl(playlistRecord, COVER_ART_SIZE, true)expect(url).toContain('pl-playlist-123')- expect(url).toContain('size=300')+ expect(url).toContain('size=600')expect(url).toContain('square=true')expect(url).toContain('_=2023-01-01T00%3A00%3A00Z')})@@ -44,10 +45,10 @@ describe('getCoverArtUrl', () => {sync: true,}- const url = subsonic.getCoverArtUrl(playlistRecord, 300, true)+ const url = subsonic.getCoverArtUrl(playlistRecord, COVER_ART_SIZE, true)expect(url).toContain('pl-playlist-123')- expect(url).toContain('size=300')+ expect(url).toContain('size=600')expect(url).toContain('square=true')expect(url).not.toContain('_=')})@@ -59,10 +60,10 @@ describe('getCoverArtUrl', () => {updatedAt: '2023-01-01T00:00:00Z',}- const url = subsonic.getCoverArtUrl(albumRecord, 300, true)+ const url = subsonic.getCoverArtUrl(albumRecord, COVER_ART_SIZE, true)expect(url).toContain('al-album-123')- expect(url).toContain('size=300')+ expect(url).toContain('size=600')expect(url).toContain('square=true')})@@ -73,10 +74,10 @@ describe('getCoverArtUrl', () => {updatedAt: '2023-01-01T00:00:00Z',}- const url = subsonic.getCoverArtUrl(songRecord, 300, true)+ const url = subsonic.getCoverArtUrl(songRecord, COVER_ART_SIZE, true)expect(url).toContain('mf-song-123')- expect(url).toContain('size=300')+ expect(url).toContain('size=600')expect(url).toContain('square=true')})@@ -86,10 +87,10 @@ describe('getCoverArtUrl', () => {updatedAt: '2023-01-01T00:00:00Z',}- const url = subsonic.getCoverArtUrl(artistRecord, 300, true)+ const url = subsonic.getCoverArtUrl(artistRecord, COVER_ART_SIZE, true)expect(url).toContain('ar-artist-123')- expect(url).toContain('size=300')+ expect(url).toContain('size=600')expect(url).toContain('square=true')})