Example #1
0
File: File.php Project: stojg/puny
 public function getURL($width, $height)
 {
     $thumbnailPath = 'assets/thumbs/' . $width . '_' . $height . '_' . $this->basename;
     $center = new \stojg\crop\CropCenter($this->filepath);
     $croppedImage = $center->resizeAndCrop($width, $height);
     #$this->enhance($croppedImage);
     $croppedImage->writeimage($thumbnailPath);
     return $thumbnailPath;
 }
Example #2
0
 protected function generateSquareThumbnail($photo, $width, $height, $cropAlgorithm = null)
 {
     $thumbnailPath = $this->getThumbnailPath($photo, $width, $height, $cropAlgorithm);
     switch ($cropAlgorithm) {
         case self::CROP_BALANCED:
             $cropper = new \stojg\crop\CropBalanced();
             break;
         case self::CROP_ENTROPY:
             $cropper = new \stojg\crop\CropEntropy();
             break;
         case self::CROP_CENTER:
         default:
             $cropper = new \stojg\crop\CropCenter();
             break;
     }
     $cropper->setImage(new \Imagick($photo->getImagePath()));
     $croppedImage = $cropper->resizeAndCrop($width, $height);
     $croppedImage->writeimage($thumbnailPath);
     $this->app['monolog']->addDebug(sprintf("Thumbnail generated: %s", $thumbnailPath));
     return $thumbnailPath;
 }