app/Http/Controllers/MediaFileController.php
private function generateImage(MediaFile $media_file, array $params): ResponseInterface
    {
        try {
            // Validate HTTP signature
            $signature = $this->glideSignature();

            $signature->validateRequest(parse_url(WT_BASE_URL . 'index.php', PHP_URL_PATH), $params);

            $server = $this->glideServer($media_file->folder());
            $path   = $server->makeImage($media_file->filename(), $params);

            return response($server->getCache()->read($path), StatusCodeInterface::STATUS_OK, [
                'Content-Type'   => $server->getCache()->getMimetype($path),
                'Content-Length' => $server->getCache()->getSize($path),
                'Cache-Control'  => 'max-age=31536000, public',
                'Expires'        => date_create('+1 years')->format('D, d M Y H:i:s') . ' GMT',
            ]);
        } catch (SignatureException $ex) {
            return $this->httpStatusAsImage(StatusCodeInterface::STATUS_FORBIDDEN);
        } catch (FileNotFoundException $ex) {
            return $this->httpStatusAsImage(StatusCodeInterface::STATUS_NOT_FOUND);
        } catch (Throwable $ex) {
            Log::addErrorLog('Cannot create thumbnail ' . $ex->getMessage());

            return $this->httpStatusAsImage(StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR);
        }
    }
private function generateImage(MediaFile $media_file, array $params): ResponseInterface
    {
        try {
            // Validate HTTP signature
            $signature = $this->glideSignature();

            $signature->validateRequest(parse_url(WT_BASE_URL . 'index.php', PHP_URL_PATH), $params);

            $server = $this->glideServer($media_file->folder());
            $path   = $server->makeImage($media_file->filename(), $params);

            return response($server->getCache()->read($path), StatusCodeInterface::STATUS_OK, [
                'Content-Type'   => $server->getCache()->getMimetype($path),
                'Content-Length' => $server->getCache()->getSize($path),
                'Cache-Control'  => 'max-age=31536000, public',
                'Expires'        => date_create('+1 years')->format('D, d M Y H:i:s') . ' GMT',
            ]);
        } catch (SignatureException $ex) {
            return $this->httpStatusAsImage(StatusCodeInterface::STATUS_FORBIDDEN);
        } catch (FileNotFoundException $ex) {
            return $this->httpStatusAsImage(StatusCodeInterface::STATUS_NOT_FOUND);
        } catch (Throwable $ex) {
            Log::addErrorLog('Cannot create thumbnail ' . $ex->getMessage());

            return $this->httpStatusAsImage(StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR);
        }
    }
private function generateImage ( MediaFile $ media_file , array $ params ) : ResponseInterface { try { // Validate HTTP signature $ signature = $ this -> glideSignature ( ) ; $ signature -> validateRequest ( parse_url ( WT_BASE_URL . 'index.php' , PHP_URL_PATH ) , $ params ) ; $ server = $ this -> glideServer ( $ media_file -> folder ( ) ) ; $ path = $ server -> makeImage ( $ media_file -> filename ( ) , $ params ) ; return response ( $ server -> getCache ( ) -> read ( $ path ) , StatusCodeInterface :: STATUS_OK , [ 'Content-Type' => $ server -> getCache ( ) -> getMimetype ( $ path ) , 'Content-Length' => $ server -> getCache ( ) -> getSize ( $ path ) , 'Cache-Control' => 'max-age=31536000, public' , 'Expires' => date_create ( '+1 years' ) -> format ( 'D, d M Y H:i:s' ) . ' GMT' , ] ) ; } catch ( SignatureException $ ex ) { return $ this -> httpStatusAsImage ( StatusCodeInterface :: STATUS_FORBIDDEN ) ; } catch ( FileNotFoundException $ ex ) { return $ this -> httpStatusAsImage ( StatusCodeInterface :: STATUS_NOT_FOUND ) ; } catch ( Throwable $ ex ) { Log :: addErrorLog ( 'Cannot create thumbnail ' . $ ex -> getMessage ( ) ) ; return $ this -> httpStatusAsImage ( StatusCodeInterface :: STATUS_INTERNAL_SERVER_ERROR ) ; } }
Generate a thumbnail image for a file.

@param MediaFile $media_file
@param array     $params

@return ResponseInterface
Generate a thumbnail image for a file .