/**
  * Builds HTTP response from given image
  *
  * @param  Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $format = $this->argument(0)->value();
     $quality = $this->argument(1)->between(0, 100)->value();
     $response = new Response($image, $format, $quality);
     $this->setOutput($response->make());
     return true;
 }
Exemplo n.º 2
0
 /**
  * Send direct output with proper header
  *
  * @param  string  $type
  * @param  integer $quality
  * @return string
  */
 public function response($type = null, $quality = 90)
 {
     // encode image in desired type (default: current type)
     $this->encode($type, $quality);
     // If this is a Laravel application, prepare response object
     if (function_exists('app') && is_a($app = app(), 'Illuminate\\Foundation\\Application')) {
         $response = \Response::make($this->encoded);
         $response->header('Content-Type', $this->mime);
         return $response;
     }
     // If this is not Laravel, set header directly
     header('Content-Type: ' . $this->mime);
     return $this->encoded;
 }