]> source.dussan.org Git - nextcloud-server.git/commitdiff
use svg to generate filetype icon if imagick available
authorGeorg Ehrke <developer@georgehrke.com>
Mon, 23 Sep 2013 07:45:36 +0000 (09:45 +0200)
committerMorris Jobke <morris.jobke@gmail.com>
Mon, 7 Oct 2013 11:19:20 +0000 (13:19 +0200)
lib/private/preview/unknown.php

index 9e6cd68d401bae46ac24c38af26b8e9de56d0ee8..9c1d41bef5a11642b4b8b263e2a0de766455bf97 100644 (file)
@@ -20,7 +20,22 @@ class Unknown extends Provider {
                $path = \OC_Helper::mimetypeIcon($mimetype);
                $path = \OC::$SERVERROOT . substr($path, strlen(\OC::$WEBROOT));
 
-               return new \OC_Image($path);
+               if (extension_loaded('imagick')) {
+                               $path = substr_replace($path, 'png', -3);
+                               $content = file_get_contents($path);
+
+                               $svg = new \Imagick();
+                               $svg->setBackgroundColor(new \ImagickPixel('transparent'));
+                               $svg->readImageBlob($content);
+                               $svg->setImageFormat('png32');
+
+                               $image = new \OC_Image();
+                               $image->loadFromData($svg);
+               } else {
+                       $image = new \OC_Image($path);
+               }
+
+               return $image;
        }
 }