private function _resizeFit(int $width, int $height, bool $resample)
    {
        $this->check();

        $src_w = $this->image_width;
        $src_h = $this->image_height;

        $k = (($src_w / $src_h) > ($width / $height) ? $src_h / $height : $src_w / $width);

        $resW = (int)round($src_w / $k);
        $resH = (int)round($src_h / $k);

        $src_x = (int)(floor(($resW - $width) / 2) * $k);
        $src_y = (int)(floor(($resH - $height) / 2) * $k);

        $res = imagecreatetruecolor($width, $height);

        if ($this->image_type == 3) {
            imagealphablending($res, false);
            imagesavealpha($res, true);
        }

        if ($resample) {
            imagecopyresampled($res, $this->image_resource, 0, 0, $src_x, $src_y, $resW, $resH, $src_w, $src_h);
        } else {
            imagecopyresized($res, $this->image_resource, 0, 0, $src_x, $src_y, $resW, $resH, $src_w, $src_h);
        }

        imagedestroy($this->image_resource);

        $this->image_resource = $res;
        $this->image_width = $resW;
        $this->image_height = $resH;

        return $this;
    }
private function _resizeFit(int $width, int $height, bool $resample)
    {
        $this->check();

        $src_w = $this->image_width;
        $src_h = $this->image_height;

        $k = (($src_w / $src_h) > ($width / $height) ? $src_h / $height : $src_w / $width);

        $resW = (int)round($src_w / $k);
        $resH = (int)round($src_h / $k);

        $src_x = (int)(floor(($resW - $width) / 2) * $k);
        $src_y = (int)(floor(($resH - $height) / 2) * $k);

        $res = imagecreatetruecolor($width, $height);

        if ($this->image_type == 3) {
            imagealphablending($res, false);
            imagesavealpha($res, true);
        }

        if ($resample) {
            imagecopyresampled($res, $this->image_resource, 0, 0, $src_x, $src_y, $resW, $resH, $src_w, $src_h);
        } else {
            imagecopyresized($res, $this->image_resource, 0, 0, $src_x, $src_y, $resW, $resH, $src_w, $src_h);
        }

        imagedestroy($this->image_resource);

        $this->image_resource = $res;
        $this->image_width = $resW;
        $this->image_height = $resH;

        return $this;
    }
private function _resizeFit ( int $ width , int $ height , bool $ resample ) { $ this -> check ( ) ; $ src_w = $ this -> image_width ; $ src_h = $ this -> image_height ; $ k = ( ( $ src_w / $ src_h ) > ( $ width / $ height ) ? $ src_h / $ height : $ src_w / $ width ) ; $ resW = ( int ) round ( $ src_w / $ k ) ; $ resH = ( int ) round ( $ src_h / $ k ) ; $ src_x = ( int ) ( floor ( ( $ resW - $ width ) / 2 ) * $ k ) ; $ src_y = ( int ) ( floor ( ( $ resH - $ height ) / 2 ) * $ k ) ; $ res = imagecreatetruecolor ( $ width , $ height ) ; if ( $ this -> image_type == 3 ) { imagealphablending ( $ res , false ) ; imagesavealpha ( $ res , true ) ; } if ( $ resample ) { imagecopyresampled ( $ res , $ this -> image_resource , 0 , 0 , $ src_x , $ src_y , $ resW , $ resH , $ src_w , $ src_h ) ; } else { imagecopyresized ( $ res , $ this -> image_resource , 0 , 0 , $ src_x , $ src_y , $ resW , $ resH , $ src_w , $ src_h ) ; } imagedestroy ( $ this -> image_resource ) ; $ this -> image_resource = $ res ; $ this -> image_width = $ resW ; $ this -> image_height = $ resH ; return $ this ; }
Resize fit with crop of redundant part

@param $width
@param $height
@param $resample

@return $this
@throws RuntimeException
Resize fit with crop of redundant part