]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix svg resizing and remove deprecated method call
authorJulius Haertl <jus@bitgrid.net>
Fri, 14 Oct 2016 19:42:25 +0000 (21:42 +0200)
committerJulius Haertl <jus@bitgrid.net>
Fri, 18 Nov 2016 09:23:24 +0000 (10:23 +0100)
Signed-off-by: Julius Haertl <jus@bitgrid.net>
apps/theming/lib/IconBuilder.php
apps/theming/lib/ThemingDefaults.php

index fac8cad430be03595f0303ceec6c64d731e0ba89..3819a2be4cb8727588e8c36f9e422d83613185d9 100644 (file)
@@ -104,13 +104,20 @@ class IconBuilder {
                        $res = $tmp->getImageResolution();
                        $tmp->destroy();
 
+                       if($x>$y) {
+                               $max = $x;
+                       } else {
+                               $max = $y;
+                       }
+
                        // convert svg to resized image
                        $appIconFile = new Imagick();
-                       $resX = (int)(512 * $res['x'] / $x * 2.53);
-                       $resY = (int)(512 * $res['y'] / $y * 2.53);
+                       $resX = (int)(512 * $res['x'] / $max * 2.53);
+                       $resY = (int)(512 * $res['y'] / $max * 2.53);
                        $appIconFile->setResolution($resX, $resY);
                        $appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
                        $appIconFile->readImageBlob($svg);
+                       $appIconFile->scaleImage(512, 512, true);
                } else {
                        $appIconFile = new Imagick();
                        $appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
index e10870685a5e4090f0f88d6df481c1332c580f19..2c344172127b6b404dd381bcd18034d9b944f518 100644 (file)
@@ -157,8 +157,8 @@ class ThemingDefaults extends \OC_Defaults {
         */
        public function shouldReplaceIcons() {
                $cache = $this->cacheFactory->create('theming');
-               if($cache->hasKey('shouldReplaceIcons')) {
-                       return (bool)$cache->get('shouldReplaceIcons');
+               if($value = $cache->get('shouldReplaceIcons')) {
+                       return (bool)$value;
                }
                $value = false;
                if(extension_loaded('imagick')) {