]> git.mxchange.org Git - friendica.git/commitdiff
only constrain horizontal image dimension for scaling very tall photos
authorfriendica <info@friendica.com>
Sat, 29 Sep 2012 12:20:29 +0000 (05:20 -0700)
committerfriendica <info@friendica.com>
Sat, 29 Sep 2012 12:20:29 +0000 (05:20 -0700)
include/Photo.php

index 00c424c64c95389fa3f487ebae758c91a6f9d011..42b54b14e86ca727b1538de5521f42d0ec0c0d0b 100644 (file)
@@ -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;