From 4fa99a762ce47387498c565f7917fa5cbeea6937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 12 Sep 2017 12:05:03 +0200 Subject: [PATCH] Theming: Generate favicon sizes to avoid resizing issues done by the browser fixes #5193 Signed-off-by: Julius Haertl --- apps/theming/lib/IconBuilder.php | 25 +++++++++++++++++++++++-- apps/theming/tests/IconBuilderTest.php | 3 +++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php index d0e26e110fccc..4b9ab1e130d48 100644 --- a/apps/theming/lib/IconBuilder.php +++ b/apps/theming/lib/IconBuilder.php @@ -54,13 +54,34 @@ public function __construct( */ 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 9b5b1933201b0..8fc0d3b62b785 100644 --- a/apps/theming/tests/IconBuilderTest.php +++ b/apps/theming/tests/IconBuilderTest.php @@ -68,6 +68,9 @@ private function checkImagick() { 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() {