adaptiveResize() public method

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
return 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);
 }