aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2017-09-12 12:05:03 +0200
committerJulius Härtl <jus@bitgrid.net>2017-11-13 10:18:47 +0100
commit31b9fc9eaca2e16d7baef3ef7e4dfc12ba0ea45e (patch)
treebaeb6e078ffed9a0ee5eb73f87156d82308d2651
parent8e61ad884738b7fe427c7e9c7451484a8ecfc0ac (diff)
downloadnextcloud-server-31b9fc9eaca2e16d7baef3ef7e4dfc12ba0ea45e.tar.gz
nextcloud-server-31b9fc9eaca2e16d7baef3ef7e4dfc12ba0ea45e.zip
Theming: Generate favicon sizes to avoid resizing issues done by the browser
fixes #5193 Signed-off-by: Julius Haertl <jus@bitgrid.net>
-rw-r--r--apps/theming/lib/IconBuilder.php25
-rw-r--r--apps/theming/tests/IconBuilderTest.php3
2 files changed, 26 insertions, 2 deletions
diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php
index 83258341985..96697687373 100644
--- a/apps/theming/lib/IconBuilder.php
+++ b/apps/theming/lib/IconBuilder.php
@@ -56,13 +56,34 @@ class IconBuilder {
*/
public function getFavicon($app) {
try {
- $icon = $this->renderAppIcon($app, 32);
+ $favicon = new Imagick();
+ $favicon->setFormat("ico");
+ $icon = $this->renderAppIcon($app, 128);
if ($icon === false) {
return false;
}
$icon->setImageFormat("png32");
- $data = $icon->getImageBlob();
+
+ $clone = clone $icon;
+ $clone->scaleImage(16,0);
+ $favicon->addImage($clone);
+
+ $clone = clone $icon;
+ $clone->scaleImage(32,0);
+ $favicon->addImage($clone);
+
+ $clone = clone $icon;
+ $clone->scaleImage(64,0);
+ $favicon->addImage($clone);
+
+ $clone = clone $icon;
+ $clone->scaleImage(128,0);
+ $favicon->addImage($clone);
+
+ $data = $favicon->getImagesBlob();
+ $favicon->destroy();
$icon->destroy();
+ $clone->destroy();
return $data;
} catch (\ImagickException $e) {
return false;
diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php
index f25f76a8180..b301fa0620d 100644
--- a/apps/theming/tests/IconBuilderTest.php
+++ b/apps/theming/tests/IconBuilderTest.php
@@ -71,6 +71,9 @@ class IconBuilderTest extends TestCase {
if (count($checkImagick->queryFormats('SVG')) < 1) {
$this->markTestSkipped('No SVG provider present.');
}
+ if (count($checkImagick->queryFormats('PNG')) < 1) {
+ $this->markTestSkipped('No PNG provider present.');
+ }
}
public function dataRenderAppIcon() {