src/Server.php
private function serveFromSource($path)
    {
        //try and load the image from the source
        if ($this->source->has($path)) {
            $file = $this->source->get($path);

            // Get the template object
            $template = $this->templates[$this->template]();

            // Process the image
            $image = $this->processImage(
                $file,
                $this->imageManager,
                $template
            );

            // Set the headers
            $this->response->headers->set('Content-Type', $image->mime);
            $this->response->headers->set('Content-Length', strlen($image->encoded));

            $lastModified = new \DateTime(); // now

            $this->setHttpCacheHeaders(
                $lastModified,
                md5($this->getCachePath().$lastModified->getTimestamp()),
                $this->maxAge
            );

            // Send the processed image in the response
            $this->response->setContent($image->encoded);

            // Setup a callback to write the processed image to the cache
            // This will be called after the image has been sent to the browser
            $this->cacheWrite = function (FilesystemInterface $cache, $path) use ($image) {
                // use put() to write or update
                $cache->put($path, $image->encoded);
            };

            return true;
        }

        return false;
    }
private function serveFromSource($path)
    {
        //try and load the image from the source
        if ($this->source->has($path)) {
            $file = $this->source->get($path);

            // Get the template object
            $template = $this->templates[$this->template]();

            // Process the image
            $image = $this->processImage(
                $file,
                $this->imageManager,
                $template
            );

            // Set the headers
            $this->response->headers->set('Content-Type', $image->mime);
            $this->response->headers->set('Content-Length', strlen($image->encoded));

            $lastModified = new \DateTime(); // now

            $this->setHttpCacheHeaders(
                $lastModified,
                md5($this->getCachePath().$lastModified->getTimestamp()),
                $this->maxAge
            );

            // Send the processed image in the response
            $this->response->setContent($image->encoded);

            // Setup a callback to write the processed image to the cache
            // This will be called after the image has been sent to the browser
            $this->cacheWrite = function (FilesystemInterface $cache, $path) use ($image) {
                // use put() to write or update
                $cache->put($path, $image->encoded);
            };

            return true;
        }

        return false;
    }
private function serveFromSource ( $ path ) { //try and load the image from the source if ( $ this -> source -> has ( $ path ) ) { $ file = $ this -> source -> get ( $ path ) ; // Get the template object $ template = $ this -> templates [ $ this -> template ] ( ) ; // Process the image $ image = $ this -> processImage ( $ file , $ this -> imageManager , $ template ) ; // Set the headers $ this -> response -> headers -> set ( 'Content-Type' , $ image -> mime ) ; $ this -> response -> headers -> set ( 'Content-Length' , strlen ( $ image -> encoded ) ) ; $ lastModified = new \ DateTime ( ) ; // now $ this -> setHttpCacheHeaders ( $ lastModified , md5 ( $ this -> getCachePath ( ) . $ lastModified -> getTimestamp ( ) ) , $ this -> maxAge ) ; // Send the processed image in the response $ this -> response -> setContent ( $ image -> encoded ) ; // Setup a callback to write the processed image to the cache // This will be called after the image has been sent to the browser $ this -> cacheWrite = function ( FilesystemInterface $ cache , $ path ) use ( $ image ) { // use put() to write or update $ cache -> put ( $ path , $ image -> encoded ) ; } ; return true ; } return false ; }
Process a source image and Generate a response object.

@param string $path Path to the source image

@return bool
Process a source image and Generate a response object .