private function serveImage(): void
    {
        if (empty($this->uriParams)) {
            \header($this->serverProtocol.' 500 Internal Server Error', true, 500);
            die();
        }

        $requestFilePath = \sprintf(
            '%s%s%s.%s',
            $this->uriParams['path'],
            $this->uriParams['file'],
            $this->getResizeParamsString(),
            $this->uriParams['extension']
        );
        $originalFilePath = \sprintf(
            '%s%s.%s',
            $this->uriParams['path'],
            $this->uriParams['file'],
            $this->uriParams['extension']
        );

        if (File::exists($requestFilePath)) {
            $this->outputImage($requestFilePath);
        }
        if (File::exists($originalFilePath)) {
            if ($this->baseClass->Image->Server->checkRefererBeforeResize === true) {
                if (!\preg_match('|^'.$this->baseClass->getServerName().'|i', $this->baseClass->getReferer())) {
                    \header($this->serverProtocol.' 403 Forbidden', true, 403);
                    die();
                }
            }

            $options = $this->uriParams['resize-params'];
            $options['quality'] = $this->baseClass->Image->Resizer->defaultQuality;

            try {
                Resizer::resize($originalFilePath, $requestFilePath, $options);
            } catch (\Exception $e) {
                \header($this->serverProtocol.' 500 Internal Server Error', true, 500);
                die();
            }
            $this->outputImage($requestFilePath);
        }

        \header($this->serverProtocol.' 404 Not Found', true, 404);
        die();
    }