Пример #1
0
 /**
  * Displays the image
  */
 public function display()
 {
     if (static::$image_resource) {
         try {
             $headers = array('Content-Disposition' => 'inline; filename="' . static::$file_name . '"', 'Last-Modified' => gmdate('r', time()), 'Cache-Control' => 'must-revalidate', 'Expires' => gmdate('r', time()), 'Content-type' => static::$file_info['mime']);
             // Use buffering to get the image data
             ob_start();
             // JPEG
             if (static::$file_info['type'] == "JPG") {
                 ImageJPEG(static::$image_resource, null, static::$image_quality);
             } elseif (static::$file_info['type'] == "GIF") {
                 ImageGIF(static::$image_resource);
             } elseif (static::$file_info['type'] == "PNG") {
                 ImagePNG(static::$image_resource, null, static::$image_quality);
             }
             $imageData = ob_get_contents();
             ob_end_clean();
             $this->destroy();
             return Resp::make($imageData, '200', $headers);
         } catch (Exception $e) {
             Error::exception($e);
         }
     }
 }
Пример #2
0
                $imwg->save($cache_image_path);
                return Resp::inline($cache_image_path, basename($image), $lifetime);
            }
        } else {
            // caching is disabled
            $imwg = Imwg::open($image);
            parseOptions($imwg, $opt);
            return $imwg->display();
            #$imwg->display();
            #exit();
        }
    }
    // No config file
    // Check if the image exists
    if (File::exists($image)) {
        return Resp::inline($image);
    }
    // No config and
    // no image found
    return Response::error('404');
});
/**
 * This parses the options to the Imwg Class
 * @param resource $imwg The Class instance
 * @param array $options Array with options to parse
 */
function parseOptions($imwg, $options)
{
    foreach ($options as $method => $params) {
        //pass through all options and check if we have that method
        if ($method == 'display' || $method == 'image_info' || $method == 'destroy') {