Example #1
0
 /**
  * Extension generator.
  * @param  Descriptor $descriptor
  * @return string
  */
 protected function getExtension(Descriptor $descriptor)
 {
     switch (strtolower(pathinfo($descriptor->getOutputFilename(), PATHINFO_EXTENSION))) {
         case 'jpg':
         case 'jpeg':
             return 'jpg';
         case 'gif':
             return 'gif';
         default:
             return 'png';
     }
 }
Example #2
0
 /**
  * Generate image from Descriptor to file.
  * @param  Descriptor $descriptor
  * @param  string     $link
  * @return Image
  */
 private function generateImage(Descriptor $descriptor, $link)
 {
     $i = $descriptor->getGeneratedImage();
     $this->onCompile($i);
     $destination = $this->destinationPath . DIRECTORY_SEPARATOR . $descriptor->getNamespace();
     if (!is_dir($destination)) {
         mkdir($destination, 0777, TRUE);
     }
     $filePath = $this->destinationPath . DIRECTORY_SEPARATOR . $descriptor->getNamespace() . basename($link);
     $i->save($filePath);
     $this->onAfterRender($filePath);
     return Image::fromFile($filePath);
 }