Exemple #1
0
 /**
  * Save the image to the given outputFile
  *
  * @param $outputFile
  * @return string the URL to the saved image
  */
 public function save($outputFile)
 {
     $glideApi = GlideApiFactory::create();
     $outputImageData = $glideApi->run(Request::create(null, null, $this->modificationParameters), file_get_contents($this->getPathToImage()));
     file_put_contents($outputFile, $outputImageData);
     return $this->getURL();
 }
 /**
  * Output a generated Glide-image
  */
 public function index()
 {
     $this->validateSignature();
     $this->writeIgnoreFile();
     $api = GlideApiFactory::create();
     $server = $this->setGlideServer($this->setImageSource(), $this->setImageCache(), $api);
     return $server->outputImage($this->request);
 }
 /**
  * Save the image to the given outputFile
  *
  * @param $outputFile
  * @return string the URL to the saved image
  */
 public function save($outputFile)
 {
     $glideApi = GlideApiFactory::create();
     $inputImageData = file_get_contents(Config::get('laravel-glide::config.source.path') . '/' . $this->imagePath);
     $outputImageData = $glideApi->run(Request::create(null, null, $this->modificationParameters), $inputImageData);
     file_put_contents($outputFile, $outputImageData);
     return $this->getURL();
 }
Exemple #4
0
 /**
  * Save the image to the given outputFile
  *
  * @param $outputFile
  * @return string the URL to the saved image
  */
 public function save($outputFile)
 {
     $glideApi = GlideApiFactory::create();
     $outputImageData = $glideApi->run(Request::create(null, null, $this->modificationParameters), $this->getPathToImage());
     file_put_contents($outputFile, $outputImageData);
     /**
      * Triggering the garbage collection solves a memory leak in an underlying package.
      */
     gc_collect_cycles();
     return $this->getURL();
 }
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->package('spatie/laravel-glide');
     $glideConfig = $this->app['config']->get('laravel-glide::config');
     $this->app['router']->get($glideConfig['baseURL'] . '/{all}', function () use($glideConfig) {
         $request = $this->app['request'];
         SignatureFactory::create($this->app['config']->get('app.key'))->validateRequest($request);
         // Set image source
         $source = new Filesystem(new Local($glideConfig['source']['path']));
         // Set image cache
         $cache = new Filesystem(new Local($glideConfig['cache']['path']));
         $this->writeIgnoreFile($glideConfig['cache']['path']);
         $api = GlideApiFactory::create();
         // Setup Glide server
         $server = new Server($source, $cache, $api);
         $server->setBaseUrl($glideConfig['baseURL']);
         echo $server->outputImage($request);
     })->where('all', '.*');
 }