adaptiveResize() 공개 메소드

This function attempts to get the image to as close to the provided dimensions as possible, and then crops the remaining overflow (from the center) to get the image to be the size specified
public adaptiveResize ( $width, $height ) : GdThumb
리턴 GdThumb
예제 #1
0
파일: Image.php 프로젝트: bkwld/croppa
 /**
  * Resize and crop
  *
  * @param integer $width
  * @param integer $height
  * @return $this
  */
 public function crop($width, $height)
 {
     // GdThumb will not enforce the requested aspect ratio if the image is too
     // small, so we manually calculate what the size should be if the aspect
     // ratio is preserved.
     $options = $this->thumb->getOptions();
     if (empty($options['resizeUp'])) {
         $size = $this->thumb->getCurrentDimensions();
         $ratio = $width / $height;
         if ($size['width'] < $width) {
             $width = $size['width'];
             $height = $size['width'] / $ratio;
         }
         if ($size['height'] < $height) {
             $height = $size['height'];
             $width = $size['height'] * $ratio;
         }
     }
     // Do a normal adpative resize
     $this->thumb->adaptiveResize($width, $height);
     return $this;
 }
예제 #2
0
 public function thumbnail($width, $height = null)
 {
     return parent::adaptiveResize($width, $height);
 }