imageManager->shouldReplaceIcons()) {
return false;
}
try {
$favicon = new Imagick();
$favicon->setFormat('ico');
$icon = $this->renderAppIcon($app, 128);
if ($icon === false) {
return false;
}
$icon->setImageFormat('png32');
$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;
}
}
/**
* @param $app string app name
* @return string|false image blob
*/
public function getTouchIcon($app) {
try {
$icon = $this->renderAppIcon($app, 512);
if ($icon === false) {
return false;
}
$icon->setImageFormat('png32');
$data = $icon->getImageBlob();
$icon->destroy();
return $data;
} catch (\ImagickException $e) {
return false;
}
}
/**
* Render app icon on themed background color
* fallback to logo
*
* @param $app string app name
* @param $size int size of the icon in px
* @return Imagick|false
*/
public function renderAppIcon($app, $size) {
$appIcon = $this->util->getAppIcon($app);
if ($appIcon === false) {
return false;
}
if ($appIcon instanceof ISimpleFile) {
$appIconContent = $appIcon->getContent();
$mime = $appIcon->getMimeType();
} else {
$appIconContent = file_get_contents($appIcon);
$mime = mime_content_type($appIcon);
}
if ($appIconContent === false || $appIconContent === '') {
return false;
}
$color = $this->themingDefaults->getColorPrimary();
// generate background image with rounded corners
$cornerRadius = 0.2 * $size;
$background = '' .
'';
// resize svg magic as this seems broken in Imagemagick
if ($mime === 'image/svg+xml' || substr($appIconContent, 0, 4) === '