newImage(SIG_WIDTH, SIG_HEIGHT, $ip_000, 'png'); $background = new Imagick(BG_PATH . DIRECTORY_SEPARATOR . BG_IMAGE); $imagick->compositeImage($background, Imagick::COMPOSITE_COPY, 0, 0); $background->destroy(); $footer = new Imagick(SIG_FOOTER); $footerHeight = $footer->getImageHeight() - ($nowPlaying ? 0 : 10); $imagick->compositeImage($footer, Imagick::COMPOSITE_MATHEMATICS, 0, SIG_HEIGHT - $footerHeight); $footer->destroy(); $imagickDraw = new ImagickDraw; $imagickDraw->setFillColor($ip_444); $imagickDraw->setFont(FW_FONT_FAM); $imagickDraw->setFontSize(FW_FONT_SIZE); $hasCover = $nowPlaying && is_file(NP_COVER_IMG); if($hasCover) { 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->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); $imagickLogo = new Imagick(); $imagickLogo->newImage($imagick->getImageWidth(), $imagick->getImageHeight(), new ImagickPixel('none'), 'png'); $imagickLogo->annotateImage( $imagickDraw, SIG_WIDTH - (4.8 * FW_FONT_SIZE) - ($hasCover ? (NP_COVER_RES + NP_COVER_PAD + NP_COVER_FRAME) : 0), SIG_HEIGHT - ($nowPlaying ? 37 : 27), 0, FW_TEXT ); $imagickShadow = clone $imagickLogo; $imagickShadow->shadowImage(.8, 5, 0, 0); $imagickShadow->compositeImage($imagickLogo, Imagick::COMPOSITE_OVER, 4, 2); $imagickLogo->destroy(); $imagick->compositeImage($imagickShadow, Imagick::COMPOSITE_OVER, -4, -2); $imagickShadow->destroy(); $imagickDraw->setFillColor($ip_fff); if($nowPlaying) { $imagickDraw->setFont(FA_FONT_FAM); $imagickDraw->setFontSize(NP_FONT_SIZE_ICON); $imagick->annotateImage($imagickDraw, 8, SIG_HEIGHT - 9, 0, "\u{f001}"); $imagickDraw->setFont(NP_FONT_FAM); $imagickDraw->setFontSize(NP_FONT_SIZE); $imagick->annotateImage($imagickDraw, 32, SIG_HEIGHT - 5, 0, $npInfo->title); $imagickDraw->setFontSize(NP_FONT_SIZE_SMALL); $imagick->annotateImage($imagickDraw, 32, SIG_HEIGHT - 20, 0, $npInfo->artist); } else { $imagickDraw->setFont(NP_FONT_FAM); $imagickDraw->setFontSize(NP_FONT_SIZE); $imagick->annotateImage($imagickDraw, 10, SIG_HEIGHT - 4, 0, "If it ain't broke, I'll break it"); } header('Content-Type: image/png'); header('Cache-Control: max-age=' . SIG_AGE . ', public'); header('Content-Disposition: inline; filename="signature.png"'); echo $imagick->getImageBlob(); $imagick->destroy(); return; } if($reqPath === '/') { $coords = explode(',', (string)filter_input(INPUT_SERVER, 'QUERY_STRING'), 3); if(count($coords) === 2) { $x = max(0, min(SIG_WIDTH, (int)$coords[0])); $y = max(0, min(SIG_HEIGHT, (int)$coords[1])); } else $x = $y = 0; http_response_code(302); if($x >= (SIG_WIDTH - SIG_HEIGHT) && $nowPlaying) { header('Location: ' . $npInfo->url); return; } header('Location: https://flash.moe'); return; } http_response_code(404); echo '404';