예제 #1
0
 /**
  * @uses $originals
  * @uses $cache
  * @uses $width_regex
  */
 public function call()
 {
     $app = $this->app;
     $cache = $this->cache;
     $originals = $this->originals;
     $app->get('/:width/:file+', function ($width, $file) use($app, $originals, $cache) {
         try {
             $source = new SplFileInfo($originals . '/' . implode("/", $file));
             $output = new SplFileInfo($cache . $app->request->getResourceUri());
             $image_factory = new ImageFactory();
             $image = $image_factory->newInstance($source);
             $box = new AutoBox($width, $width, $image);
             new Workflow($image, $box, $output);
         } catch (FileNotFound $e) {
             $app->notFound();
         }
     })->conditions(array('width' => $this->width_regex));
     // Call the next middleware
     $this->next->call();
 }
예제 #2
0
 /**
  * @uses $originals
  * @uses $cache
  * @uses $crop_regex
  */
 public function call()
 {
     $app = $this->app;
     $cache = $this->cache;
     $originals = $this->originals;
     // ======================
     // URLs containing s.th. like "/300x150/path/to/image.jpg"
     // ======================
     $app->get('/:width_and_height/:file+', function ($width_and_height, $file) use($app, $originals, $cache) {
         list($width, $height) = explode('x', $width_and_height);
         try {
             $source = new SplFileInfo($originals . '/' . implode("/", $file));
             $output = new SplFileInfo($cache . $app->request->getResourceUri());
             $image_factory = new ImageFactory();
             $image = $image_factory->newInstance($source);
             $box = new CropBox($width, $height, $image);
             new Workflow($image, $box, $output);
         } catch (FileNotFound $e) {
             $app->notFound();
         }
     })->conditions(array('width_and_height' => $this->crop_regex));
     // Call the next middleware
     $this->next->call();
 }