Newscoop\Image\Rendition::getThumbnail PHP Метод

getThumbnail() публичный Метод

Get thumbnail
public getThumbnail ( Newscoop\Image\ImageInterface $image, ImageService $imageService ) : Newscoop\Image\Thumbnail
$image Newscoop\Image\ImageInterface
$imageService ImageService
Результат Newscoop\Image\Thumbnail
    public function getThumbnail(ImageInterface $image, ImageService $imageService)
    {
        if (!$this->fits($image)) {
            throw new \InvalidArgumentException("Image is too small.");
        }
        list($width, $height) = \Newscoop\Image\ImageService::calculateSize($image->getWidth(), $image->getHeight(), $this->width, $this->height, $this->getFlags());
        if ($this->isCrop()) {
            $width = min($width, $this->width);
            $height = min($height, $this->height);
        }
        return new Thumbnail($imageService->getSrc($image->getPath(), $this->width, $this->height, $this->getSpecs()), $width, $height);
    }

Usage Example

Пример #1
0
 /**
  * Get thumbnail for given image and rendition
  *
  * @param Newscoop\Image\Rendition      $rendition
  * @param Newscoop\Image\ImageInterface $image
  *
  * @return Newscoop\Image\Thumbnail
  */
 public function getThumbnail(Rendition $rendition, ImageInterface $image)
 {
     return $rendition->getThumbnail($image, $this);
 }
All Usage Examples Of Newscoop\Image\Rendition::getThumbnail