From: Marcel Werk Date: Tue, 28 May 2013 22:40:04 +0000 (+0200) Subject: Optimized avatar upload X-Git-Tag: 2.0.0_Beta_1~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=155d9e0fa676becc41fc4f0a7c5b65479bbd4111;p=GitHub%2FWoltLab%2FWCF.git Optimized avatar upload --- diff --git a/wcfsetup/install/files/lib/data/user/avatar/UserAvatarAction.class.php b/wcfsetup/install/files/lib/data/user/avatar/UserAvatarAction.class.php index 3d6404cb7c..16927efdf6 100644 --- a/wcfsetup/install/files/lib/data/user/avatar/UserAvatarAction.class.php +++ b/wcfsetup/install/files/lib/data/user/avatar/UserAvatarAction.class.php @@ -258,10 +258,18 @@ class UserAvatarAction extends AbstractDatabaseObjectAction { $imageData = getimagesize($filename); if ($imageData[0] > MAX_AVATAR_WIDTH || $imageData[1] > MAX_AVATAR_HEIGHT) { try { + $obtainDimensions = true; + if (MAX_AVATAR_WIDTH / $imageData[0] < MAX_AVATAR_HEIGHT / $imageData[1]) { + if (round($imageData[1] * (MAX_AVATAR_WIDTH / $imageData[0])) < 48) $obtainDimensions = false; + } + else { + if (round($imageData[0] * (MAX_AVATAR_HEIGHT / $imageData[1])) < 48) $obtainDimensions = false; + } + $adapter = ImageHandler::getInstance()->getAdapter(); $adapter->loadFile($filename); $filename = FileUtil::getTemporaryFilename(); - $thumbnail = $adapter->createThumbnail(MAX_AVATAR_WIDTH, MAX_AVATAR_HEIGHT, false); + $thumbnail = $adapter->createThumbnail(MAX_AVATAR_WIDTH, MAX_AVATAR_HEIGHT, $obtainDimensions); $adapter->writeImage($thumbnail, $filename); } catch (SystemException $e) {