Esempio n. 1
0
 /**
  * Resizes maintaining aspect ratio but not exceeding width / height.
  *
  * @param  mixed $width  Can be just max width or an array containing both params.
  * @param  int   $height Max height.
  * @return Image
  */
 public function reduce($width, $height = null)
 {
     list($width, $height) = Normalize::size($width, $height);
     if ($this->width < $width && $this->height < $height) {
         return $this;
     }
     $ratioX = $this->width / $width;
     $ratioY = $this->height / $height;
     $ratio = $ratioX > $ratioY ? $ratioX : $ratioY;
     if ($ratio === 1) {
         return $this;
     }
     // Getting the new image size
     $width = (int) ($this->width / $ratio);
     $height = (int) ($this->height / $ratio);
     $this->image = $this->imagecopy($width, $height);
     $this->updateSize();
     return $this;
 }
Esempio n. 2
0
 /**
  * @expectedException Elboletaire\Watimage\Exception\InvalidArgumentException
  */
 public function testSizeFail()
 {
     Normalize::size(null);
 }