src/classes/CCImage.php
public static function aspect_ratio( $width, $height, $proper = false ) 
	{
		$ratio = $width / $height;

		if ( !$proper ) 
		{
			return $ratio;
		}

		$tolerance = 1.e-6;
		$h1=1; $h2=0;
		$k1=0; $k2=1;
		$b = 1/$ratio;

		do {
			$b = 1/$b;
			$a = floor($b);
			$aux = $h1; $h1 = $a*$h1+$h2; $h2 = $aux;
			$aux = $k1; $k1 = $a*$k1+$k2; $k2 = $aux;
			$b = $b-$a;

		} while ( abs( $ratio-$h1 / $k1 ) > $ratio * $tolerance );

		return $h1.":".$k1;
	}
public static function aspect_ratio( $width, $height, $proper = false ) 
	{
		$ratio = $width / $height;

		if ( !$proper ) 
		{
			return $ratio;
		}

		$tolerance = 1.e-6;
		$h1=1; $h2=0;
		$k1=0; $k2=1;
		$b = 1/$ratio;

		do {
			$b = 1/$b;
			$a = floor($b);
			$aux = $h1; $h1 = $a*$h1+$h2; $h2 = $aux;
			$aux = $k1; $k1 = $a*$k1+$k2; $k2 = $aux;
			$b = $b-$a;

		} while ( abs( $ratio-$h1 / $k1 ) > $ratio * $tolerance );

		return $h1.":".$k1;
	}
public static function aspect_ratio ( $ width , $ height , $ proper = false ) { $ ratio = $ width / $ height ; if ( ! $ proper ) { return $ ratio ; } $ tolerance = 1.e-6 ; $ h1 = 1 ; $ h2 = 0 ; $ k1 = 0 ; $ k2 = 1 ; $ b = 1 / $ ratio ; do { $ b = 1 / $ b ; $ a = floor ( $ b ) ; $ aux = $ h1 ; $ h1 = $ a * $ h1 + $ h2 ; $ h2 = $ aux ; $ aux = $ k1 ; $ k1 = $ a * $ k1 + $ k2 ; $ k2 = $ aux ; $ b = $ b - $ a ; } while ( abs ( $ ratio - $ h1 / $ k1 ) > $ ratio * $ tolerance ) ; return $ h1 . ":" . $ k1 ; }
Calculate the aspect ratio

@param int	$width
@param int 	$height
@param bool	$proper

@return string

@thanks to: http://jonisalonen.com/2012/converting-decimal-numbers-to-ratios/
Calculate the aspect ratio