diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2014-05-26 08:28:02 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2014-05-26 08:28:02 +0400 |
commit | 1c6bd97db82d657ec76e6e3d7dc34471db122d41 (patch) | |
tree | aa9ffe3db87465fc8fbcf915c064bec71ca2b1eb /plugins/CoreAdminHome/CustomLogo.php | |
parent | 76f7d382fd2bcd5e94d0a7116e44fa2e4bac02e6 (diff) | |
parent | 24a45dee285d1c44ae38e5e1baa7773b1eb7bc6a (diff) |
Merge remote-tracking branch 'origin/master' into morpheus_defaulttheme
Conflicts:
plugins/CoreHome/angularjs/siteselector/siteselector.less
Diffstat (limited to 'plugins/CoreAdminHome/CustomLogo.php')
-rw-r--r-- | plugins/CoreAdminHome/CustomLogo.php | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/plugins/CoreAdminHome/CustomLogo.php b/plugins/CoreAdminHome/CustomLogo.php index b4f6884793..892cb758f0 100644 --- a/plugins/CoreAdminHome/CustomLogo.php +++ b/plugins/CoreAdminHome/CustomLogo.php @@ -88,7 +88,7 @@ class CustomLogo $directoryWritingTo = PIWIK_DOCUMENT_ROOT . '/' . dirname($pathUserLogo); // Create directory if not already created - Filesystem::mkdir($directoryWritingTo, $denyAccess = false); + Filesystem::mkdir($directoryWritingTo); $directoryWritable = is_writable($directoryWritingTo); $logoFilesWriteable = is_writeable(PIWIK_DOCUMENT_ROOT . '/' . $pathUserLogo) @@ -195,21 +195,20 @@ class CustomLogo return false; } - $smallWidthExpected = round($width * $targetHeight / $height); + $targetWidth = round($width * $targetHeight / $height); - $logoSmall = imagecreatetruecolor($smallWidthExpected, $targetHeight); - - // Handle transparency - $backgroundSmall = imagecolorallocate($logoSmall, 0, 0, 0); - imagecolortransparent($logoSmall, $backgroundSmall); + $newImage = imagecreatetruecolor($targetWidth, $targetHeight); if ($_FILES[$uploadFieldName]['type'] == 'image/png') { - imagealphablending($logoSmall, false); - imagesavealpha($logoSmall, true); + imagealphablending($newImage, false); + imagesavealpha($newImage, true); } - imagecopyresized($logoSmall, $image, 0, 0, 0, 0, $smallWidthExpected, $targetHeight, $width, $height); - imagepng($logoSmall, PIWIK_DOCUMENT_ROOT . '/' . $userPath, 3); + $backgroundColor = imagecolorallocate($newImage, 0, 0, 0); + imagecolortransparent($newImage, $backgroundColor); + + imagecopyresampled($newImage, $image, 0, 0, 0, 0, $targetWidth, $targetHeight, $width, $height); + imagepng($newImage, PIWIK_DOCUMENT_ROOT . '/' . $userPath, 3); return true; } |