Пример #1
0
 /**
  * Checks image is square.
  *
  * @param T_Image_Gd $value  image to filter
  * @return mixed  filtered value
  */
 protected function doTransform($value)
 {
     if ($value->getWidth() !== $value->getHeight()) {
         $msg = "must be square (i.e. width equal to height)";
         throw new T_Exception_Filter($msg);
     }
     return $value;
 }
Пример #2
0
 /**
  * Checks image is within height range.
  *
  * @param T_Image_Gd $value  image to filter
  * @return mixed  filtered value
  */
 protected function doTransform($value)
 {
     if (!is_null($this->min) && $value->getHeight() < $this->min) {
         $msg = "is too small an image. The minimum height is {$this->min} pixels";
         throw new T_Exception_Filter($msg);
     }
     if (!is_null($this->max) && $value->getHeight() > $this->max) {
         $msg = "is too big an image. The maximum height is {$this->max} pixels";
         throw new T_Exception_Filter($msg);
     }
     return $value;
 }
Пример #3
0
 /**
  * Checks image is within width range.
  *
  * @param T_Image_Gd $value  image to filter
  * @return mixed  filtered value
  */
 protected function doTransform($value)
 {
     $aspect = $value->getWidth() / $value->getHeight();
     if (!is_null($this->min) && $aspect < $this->min) {
         $min = round($this->min, 2);
         $msg = "has too small an aspect ratio (width/height). The minimum is {$min}";
         throw new T_Exception_Filter($msg);
     }
     if (!is_null($this->max) && $aspect > $this->max) {
         $max = round($this->max, 2);
         $msg = "has too large an aspect ratio (width/height). The minimum is {$max}";
         throw new T_Exception_Filter($msg);
     }
     return $value;
 }
Пример #4
0
 function testResizeBothDimsTooBigBothConstrained()
 {
     $im = new T_Image_Gd(100, 200);
     $new = $im->resize(50, 100);
     $this->assertSame($new->getWidth(), 50);
     $this->assertSame($new->getHeight(), 100);
 }