From ce9a50e7099384e520ab7386b49d66b6e66b1cc0 Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 21 Jun 2023 00:31:15 +0000 Subject: [PATCH] Fixed cover read error. --- public/index.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/public/index.php b/public/index.php index b2e2393..24cb892 100644 --- a/public/index.php +++ b/public/index.php @@ -57,18 +57,24 @@ if(in_array($reqPath, [ $hasCover = $nowPlaying && is_file(NP_COVER_IMG); if($hasCover) { - $imagickDraw->rectangle( - SIG_WIDTH - (NP_COVER_RES + NP_COVER_PAD) - NP_COVER_FRAME, - NP_COVER_PAD - NP_COVER_FRAME, - SIG_WIDTH - (NP_COVER_RES + NP_COVER_PAD) + NP_COVER_RES, - NP_COVER_PAD + NP_COVER_RES, - ); - $imagick->drawImage($imagickDraw); + try { + $imagickDraw->rectangle( + SIG_WIDTH - (NP_COVER_RES + NP_COVER_PAD) - NP_COVER_FRAME, + NP_COVER_PAD - NP_COVER_FRAME, + SIG_WIDTH - (NP_COVER_RES + NP_COVER_PAD) + NP_COVER_RES, + NP_COVER_PAD + NP_COVER_RES, + ); - $npCover = new Imagick(NP_COVER_IMG); - $npCover->resizeImage(NP_COVER_RES, NP_COVER_RES, Imagick::FILTER_CATROM, 0.9, true); - $imagick->compositeImage($npCover, Imagick::COMPOSITE_COPY, SIG_WIDTH - (NP_COVER_RES + NP_COVER_PAD), NP_COVER_PAD); - $npCover->destroy(); + $npCover = new Imagick(NP_COVER_IMG); + $npCover->resizeImage(NP_COVER_RES, NP_COVER_RES, Imagick::FILTER_CATROM, 0.9, true); + + $imagick->drawImage($imagickDraw); + $imagick->compositeImage($npCover, Imagick::COMPOSITE_COPY, SIG_WIDTH - (NP_COVER_RES + NP_COVER_PAD), NP_COVER_PAD); + + $npCover->destroy(); + } catch(ImagickException $ex) { + $hasCover = false; + } } $imagickDraw->setFillColor(BG_IMAGE === 'bg4.png' ? $ip_000 : $ip_fff);