Exemple #1
0
 /**
  * Resize an image with optimised settings for slightly reduced quality and significantly
  * reduced file size.
  *
  * @param BoxInterface $size
  * @param boolean      $optimize   Whether you intend to perform optimization on the resulting image.
  *                                 Note that setting this to `true` doesn’t actually perform any optimization.
  * @param integer      $quality    Defaults to 82 which produces a very similar image.
  *
  * @return ImageInterface
  * @throws \Imagine\Exception\RuntimeException
  */
 public function smartResize(BoxInterface $size, $optimize = false, $quality = 82)
 {
     try {
         if ($this->imagick instanceof Imagick) {
             $this->imagick->smartResize($size->getWidth(), $size->getHeight(), $optimize, $quality);
         } else {
             $this->resize($size);
         }
     } catch (\ImagickException $e) {
         throw new RuntimeException('Resize operation failed', $e->getCode(), $e);
     }
     return $this;
 }