From: Hypolite Petovan Date: Wed, 28 Dec 2022 18:12:30 +0000 (-0500) Subject: Merge pull request #12557 from annando/reduce-update-contacts X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=689b6b015b84da4b8ce2bdb2389093e5d104b2c9;hp=088a3b6bc429973381e6eb2931c6eacd5b8c8927;p=friendica.git Merge pull request #12557 from annando/reduce-update-contacts Reduce the amount of "UpdateContact" worker calls --- diff --git a/src/Object/Image.php b/src/Object/Image.php index 1d2832f20a..62bc8d897f 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -285,49 +285,13 @@ class Image $width = $this->getWidth(); $height = $this->getHeight(); - if ((! $width)|| (! $height)) { - 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; - } + $scale = Images::getScalingDimensions($width, $height, $max); + if ($scale) { + return $this->scale($scale['width'], $scale['height']); } 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 false; } - return $this->scale($dest_width, $dest_height); } /**