]> git.mxchange.org Git - friendica.git/commitdiff
Fix resizing
authorMichael <heluecht@pirati.ca>
Mon, 28 Jun 2021 19:38:03 +0000 (19:38 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 28 Jun 2021 19:38:03 +0000 (19:38 +0000)
src/Module/Photo.php

index 4d24c48e29eedc534c8f1c2c2f53a5c573fb8764..05ddd1bf50369aa707af25034885d50550d890e0 100644 (file)
@@ -63,6 +63,7 @@ class Photo extends BaseModule
                }
 
                $customsize = 0;
+               $square_resize = true;
                $photo = false;
                $scale = null;
                $stamp = microtime(true);
@@ -70,6 +71,7 @@ class Photo extends BaseModule
                        $customsize = intval($parameters['customsize']);
                        $uid = MPhoto::stripExtension($parameters['name']);
                        $photo = self::getAvatar($uid, $parameters['type'], $customsize);
+                       $square_resize = !in_array($parameters['type'], ['media', 'preview']);
                } elseif (!empty($parameters['type'])) {
                        $uid = MPhoto::stripExtension($parameters['name']);
                        $photo = self::getAvatar($uid, $parameters['type'], Proxy::PIXEL_SMALL);
@@ -105,10 +107,14 @@ class Photo extends BaseModule
                }
 
                // if customsize is set and image is not a gif, resize it
-               if ($photo['type'] !== "image/gif" && $customsize > 0 && $customsize < 501) {
+               if ($photo['type'] !== "image/gif" && $customsize > 0 && $customsize <= Proxy::PIXEL_THUMB && $square_resize) {
                        $img = new Image($imgdata, $photo['type']);
                        $img->scaleToSquare($customsize);
                        $imgdata = $img->asString();
+               } elseif ($photo['type'] !== "image/gif" && $customsize > 0) {
+                       $img = new Image($imgdata, $photo['type']);
+                       $img->scaleDown($customsize);
+                       $imgdata = $img->asString();
                }
 
                if (function_exists("header_remove")) {