Exemple #1
0
 /**
  * Crops the image and saves it to the original image's path
  *      
  * @param integer $x
  * @param integer $y
  * @param integer $width
  * @param integer $height
  * @param string $path destination
  * 
  * @return string Generated name for the cropped image
  * @throws \Exception
  */
 public function handle($x, $y, $width, $height, $path)
 {
     if (!in_array($this->getImage()->getExtension(), array('jpg', 'jpeg', 'png', 'gif'))) {
         throw new \Exception('Image format is not supported.');
     }
     $image = $this->getImage();
     $uniqueId = \Jabba\File::getRandomString();
     $src = $image->getPath();
     $dest = \Jabba\File\Image::getPathByName($path, $uniqueId, 3, true) . $uniqueId . '.' . $image->getExtension();
     $this->_handle($src, $dest, $x, $y, $width, $height);
     return new \Jabba\File\Image($dest);
 }
Exemple #2
0
 public function __construct($path)
 {
     parent::__construct($path);
     $size = getImageSize($this->getPath());
     $this->setWidth($size[0])->setHeight($size[1]);
 }