Skip to content

Commit

Permalink
Theming: Generate favicon sizes to avoid resizing issues done by the …
Browse files Browse the repository at this point in the history
…browser

fixes #5193

Signed-off-by: Julius Haertl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Sep 23, 2017
1 parent d4bf301 commit 4fa99a7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
25 changes: 23 additions & 2 deletions apps/theming/lib/IconBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions apps/theming/tests/IconBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 4fa99a7

Please sign in to comment.