public function fitResize($max_width = 150, $max_height = 150, $min_width = 20, $min_height = 20) {
        $kw = $max_width / $this->width();
        $kh = $max_height / $this->height();
        if($kw > $kh) {
            $new_h = $max_height;
            $new_w = round($kh * $this->width());
        } else {
            $new_w = $max_width;
            $new_h = round($kw * $this->height());
        }
        $this->resize($new_w, $new_h);

        // Method chaining
        return $this;
    }
public function fitResize($max_width = 150, $max_height = 150, $min_width = 20, $min_height = 20) {
        $kw = $max_width / $this->width();
        $kh = $max_height / $this->height();
        if($kw > $kh) {
            $new_h = $max_height;
            $new_w = round($kh * $this->width());
        } else {
            $new_w = $max_width;
            $new_h = round($kw * $this->height());
        }
        $this->resize($new_w, $new_h);

        // Method chaining
        return $this;
    }
public function fitResize ( $ max_width = 150 , $ max_height = 150 , $ min_width = 20 , $ min_height = 20 ) { $ kw = $ max_width / $ this -> width ( ) ; $ kh = $ max_height / $ this -> height ( ) ; if ( $ kw > $ kh ) { $ new_h = $ max_height ; $ new_w = round ( $ kh * $ this -> width ( ) ) ; } else { $ new_w = $ max_width ; $ new_h = round ( $ kw * $ this -> height ( ) ) ; } $ this -> resize ( $ new_w , $ new_h ) ; // Method chaining return $ this ; }
Fit the image with the same proportion into an area

@param int $max_width
@param int $max_height
@param int $min_width
@param int $min_height
@return Image
Fit the image with the same proportion into an area