From: friendica Date: Sat, 29 Sep 2012 12:20:29 +0000 (-0700) Subject: only constrain horizontal image dimension for scaling very tall photos X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0693afd6b74988b1527fe771d64d3c5e14cef84a;p=friendica.git only constrain horizontal image dimension for scaling very tall photos --- diff --git a/include/Photo.php b/include/Photo.php index 00c424c64c..42b54b14e8 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -227,7 +227,18 @@ class Photo { return FALSE; if($width > $max && $height > $max) { - if($width > $height) { + + // very tall image (greater than 16:9) + // constrain the width - let the height float. + + if((($height * 9) / 16) > $width) { + $dest_width = $max; + $dest_height = intval(( $height * $max ) / $width); + } + + // else constrain both dimensions + + elseif($width > $height) { $dest_width = $max; $dest_height = intval(( $height * $max ) / $width); } @@ -243,8 +254,18 @@ class Photo { } else { if( $height > $max ) { - $dest_width = intval(( $width * $max ) / $height); - $dest_height = $max; + + // very tall image (greater than 16:9) + // constrain the width - let the height float. + + if((($height * 9) / 16) > $width) { + $dest_width = $max; + $dest_height = intval(( $height * $max ) / $width); + } + else { + $dest_width = intval(( $width * $max ) / $height); + $dest_height = $max; + } } else { $dest_width = $width;