summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2016-12-04 16:09:12 +0100
committerGitHub <noreply@github.com>2016-12-04 16:09:12 +0100
commit3234d4b36cca943ba1cb7ae200ef14b7fcb3456f (patch)
tree267bd019dd466e451f9fedabf329d752d4c636b4 /apps
parent3bea7ac6acd31f1de71d800b739fbc654ba92b63 (diff)
parentfd6670ae7287b6de33a19db2fa218eef3194e088 (diff)
downloadnextcloud-server-3234d4b36cca943ba1cb7ae200ef14b7fcb3456f.tar.gz
nextcloud-server-3234d4b36cca943ba1cb7ae200ef14b7fcb3456f.zip
Merge pull request #2497 from nextcloud/theming-icon-fixes
Fixing issues with themed icons
Diffstat (limited to 'apps')
-rw-r--r--apps/theming/lib/IconBuilder.php14
-rw-r--r--apps/theming/tests/IconBuilderTest.php2
2 files changed, 9 insertions, 7 deletions
diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php
index d8161051ebb..9cf0d051304 100644
--- a/apps/theming/lib/IconBuilder.php
+++ b/apps/theming/lib/IconBuilder.php
@@ -52,11 +52,10 @@ class IconBuilder {
* @return string|false image blob
*/
public function getFavicon($app) {
- $icon = $this->renderAppIcon($app);
+ $icon = $this->renderAppIcon($app, 32);
if($icon === false) {
return false;
}
- $icon->resizeImage(32, 32, Imagick::FILTER_LANCZOS, 1);
$icon->setImageFormat("png24");
$data = $icon->getImageBlob();
$icon->destroy();
@@ -68,7 +67,7 @@ class IconBuilder {
* @return string|false image blob
*/
public function getTouchIcon($app) {
- $icon = $this->renderAppIcon($app);
+ $icon = $this->renderAppIcon($app, 512);
if($icon === false) {
return false;
}
@@ -83,9 +82,10 @@ class IconBuilder {
* fallback to logo
*
* @param $app string app name
+ * @param $size int size of the icon in px
* @return Imagick|false
*/
- public function renderAppIcon($app) {
+ public function renderAppIcon($app, $size) {
try {
$appIcon = $this->util->getAppIcon($app);
$appIconContent = file_get_contents($appIcon);
@@ -103,7 +103,7 @@ class IconBuilder {
// generate background image with rounded corners
$background = '<?xml version="1.0" encoding="UTF-8"?>' .
'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">' .
- '<rect x="0" y="0" rx="75" ry="75" width="512" height="512" style="fill:' . $color . ';" />' .
+ '<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' .
'</svg>';
// resize svg magic as this seems broken in Imagemagick
if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
@@ -153,11 +153,13 @@ class IconBuilder {
$appIconFile->setImageFormat("png24");
$finalIconFile = new Imagick();
+ $finalIconFile->setBackgroundColor(new ImagickPixel('transparent'));
$finalIconFile->readImageBlob($background);
$finalIconFile->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$finalIconFile->setImageArtifact('compose:args', "1,0,-0.5,0.5");
$finalIconFile->compositeImage($appIconFile, Imagick::COMPOSITE_ATOP, $offset_w, $offset_h);
- $finalIconFile->resizeImage(512, 512, Imagick::FILTER_LANCZOS, 1);
+ $finalIconFile->setImageFormat('png24');
+ $finalIconFile->resizeImage($size, $size, Imagick::INTERPOLATE_BICUBIC, 1, false);
$appIconFile->destroy();
return $finalIconFile;
diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php
index 54850c8f3c2..da27795ce2c 100644
--- a/apps/theming/tests/IconBuilderTest.php
+++ b/apps/theming/tests/IconBuilderTest.php
@@ -91,7 +91,7 @@ class IconBuilderTest extends TestCase {
->willReturn($color);
$expectedIcon = new \Imagick(realpath(dirname(__FILE__)). "/data/" . $file);
- $icon = $this->iconBuilder->renderAppIcon($app);
+ $icon = $this->iconBuilder->renderAppIcon($app, 512);
$this->assertEquals(true, $icon->valid());
$this->assertEquals(512, $icon->getImageWidth());