summaryrefslogtreecommitdiffstats
path: root/apps/theming
diff options
context:
space:
mode:
authorJulius Haertl <jus@bitgrid.net>2016-12-04 13:02:17 +0100
committerJulius Haertl <jus@bitgrid.net>2016-12-04 13:38:29 +0100
commit797e7614925d10f8a11ae239f2122497d0f01fc2 (patch)
tree424e1b575ac8440edef5bb361608bd4422517edc /apps/theming
parentdb56df18939fcdadd2b19ebab7db92a77e938c8d (diff)
downloadnextcloud-server-797e7614925d10f8a11ae239f2122497d0f01fc2.tar.gz
nextcloud-server-797e7614925d10f8a11ae239f2122497d0f01fc2.zip
Move sizing to renderAppIcon method
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming')
-rw-r--r--apps/theming/lib/IconBuilder.php11
-rw-r--r--apps/theming/tests/IconBuilderTest.php2
2 files changed, 7 insertions, 6 deletions
diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php
index d8161051ebb..570b3411049 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);
@@ -157,7 +157,8 @@ class IconBuilder {
$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());