/**
  * Store image into cache, create resized image if necessary.
  *
  * @param string $imageName
  * @param array  $options
  */
 private function generateAndStoreImage($imageName, array $options)
 {
     // if both axles set to 0 we simply store default image
     if ($options['width'] === 0 && $options['height'] === 0) {
         $this->imageMap->insert($imageName, $imageName, 0, 0, 1);
     } else {
         $resizer = new Resizer();
         // first we need the default image to be loaded
         $default = new SimpleImage($this->basedir, $this->fileName);
         // resize image with given options and store it onto disk
         $this->image = $resizer->resizeImage($default->image, $options);
         // generate cached image file name
         list($width, $height) = Resizer::getDimensions($this->image);
         $fileName = $this->generateFileName($this->fullPath, $width, $height);
         $this->storeImage($this->image, $fileName);
         // insert entry into cache
         $this->imageMap->insert($imageName, $fileName, $width, $height, $resizer->keepAspectRatio());
     }
 }
Example #2
0
 /**
  * @return string
  */
 public function render()
 {
     return $this->_imageMap->render();
 }