]> git.mxchange.org Git - friendica.git/commitdiff
Replaced the doubled code in for getScalingDimension with Images::getScalingDimensio...
authorMarek Bachmann <marek.bachmann@comtec.eecs.uni-kassel.de>
Wed, 28 Dec 2022 02:30:56 +0000 (03:30 +0100)
committerMarek Bachmann <marek.bachmann@comtec.eecs.uni-kassel.de>
Wed, 28 Dec 2022 02:30:56 +0000 (03:30 +0100)
src/Object/Image.php

index 1d2832f20a9a075ab6f2df3b8c08395eedd60866..430ad6f139155b56e68ae8e523ab9bdf99a9bfd7 100644 (file)
@@ -289,45 +289,8 @@ class Image
                        return false;
                }
 
-               if ($width > $max && $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);
-                       } elseif ($width > $height) {
-                               // else constrain both dimensions
-                               $dest_width = $max;
-                               $dest_height = intval(($height * $max) / $width);
-                       } else {
-                               $dest_width = intval(($width * $max) / $height);
-                               $dest_height = $max;
-                       }
-               } else {
-                       if ($width > $max) {
-                               $dest_width = $max;
-                               $dest_height = intval(($height * $max) / $width);
-                       } else {
-                               if ($height > $max) {
-                                       // very tall image (greater than 16:9)
-                                       // but width is OK - don't do anything
-
-                                       if ((($height * 9) / 16) > $width) {
-                                               $dest_width = $width;
-                                               $dest_height = $height;
-                                       } else {
-                                               $dest_width = intval(($width * $max) / $height);
-                                               $dest_height = $max;
-                                       }
-                               } else {
-                                       $dest_width = $width;
-                                       $dest_height = $height;
-                               }
-                       }
-               }
-
-               return $this->scale($dest_width, $dest_height);
+               $scale = Images::getScalingDimensions($width, $height,$max);
+               return $this->scale($scale['width'], $scale['height']);
        }
 
        /**