src/Image.php
public function getConstrainedDimensions($curW, $curH, $maxW, $maxH)
	{
	    $this->debug->groupCollapsed(__METHOD__);
	    $ratio = $curW / $curH;   // > 1 = wider than tall (landscape) < 1 = portrait
	    $return = array('w' => $curW, 'h' => $curH);
	    if ($return['w'] > $maxW) {
	        $this->debug->log('fitting to maxW');
	        $return = array(
	            'w' => $maxW,
	            'h' => round($maxW / $ratio)
	        );
	    }
	    if ($return['h'] > $maxH) {
	        $this->debug->log('fitting to maxH');
	        $return = array(
	            'w' => round($maxH * $ratio),
	            'h' => $maxH
	        );
	    }
	    // $this->debug->log('return', $return);
	    $this->debug->groupEnd();
	    return $return;
	}
public function getConstrainedDimensions($curW, $curH, $maxW, $maxH)
	{
	    $this->debug->groupCollapsed(__METHOD__);
	    $ratio = $curW / $curH;   // > 1 = wider than tall (landscape) < 1 = portrait
	    $return = array('w' => $curW, 'h' => $curH);
	    if ($return['w'] > $maxW) {
	        $this->debug->log('fitting to maxW');
	        $return = array(
	            'w' => $maxW,
	            'h' => round($maxW / $ratio)
	        );
	    }
	    if ($return['h'] > $maxH) {
	        $this->debug->log('fitting to maxH');
	        $return = array(
	            'w' => round($maxH * $ratio),
	            'h' => $maxH
	        );
	    }
	    // $this->debug->log('return', $return);
	    $this->debug->groupEnd();
	    return $return;
	}
public function getConstrainedDimensions ( $ curW , $ curH , $ maxW , $ maxH ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ ratio = $ curW / $ curH ; // > 1 = wider than tall (landscape) < 1 = portrait $ return = array ( 'w' => $ curW , 'h' => $ curH ) ; if ( $ return [ 'w' ] > $ maxW ) { $ this -> debug -> log ( 'fitting to maxW' ) ; $ return = array ( 'w' => $ maxW , 'h' => round ( $ maxW / $ ratio ) ) ; } if ( $ return [ 'h' ] > $ maxH ) { $ this -> debug -> log ( 'fitting to maxH' ) ; $ return = array ( 'w' => round ( $ maxH * $ ratio ) , 'h' => $ maxH ) ; } // $this->debug->log('return', $return); $ this -> debug -> groupEnd ( ) ; return $ return ; }
Get the dimensions to fit an image to maxw and maxH

@param integer $curW current width
@param integer $curH current height
@param integer $maxW maximum width
@param integer $maxH maximum height

@return array
Get the dimensions to fit an image to maxw and maxH