summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-11 00:12:37 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-11 00:12:37 +0200
commit19ea4f79da63f640678c7eae0511f342ea2474b5 (patch)
tree5fa35b1987600e588b9c38abd81441610a4553e0
parentbe4aea2d1b5215a014ab4ae78ea0aa5ea076b48c (diff)
downloadnextcloud-server-19ea4f79da63f640678c7eae0511f342ea2474b5.tar.gz
nextcloud-server-19ea4f79da63f640678c7eae0511f342ea2474b5.zip
resize svg without loosing quality
-rw-r--r--lib/private/preview/unknown.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/private/preview/unknown.php b/lib/private/preview/unknown.php
index 62444ac6a24..4747f9e25ed 100644
--- a/lib/private/preview/unknown.php
+++ b/lib/private/preview/unknown.php
@@ -23,7 +23,15 @@ class Unknown extends Provider {
$svgPath = substr_replace($path, 'svg', -3);
if (extension_loaded('imagick') && file_exists($svgPath)) {
+
+ // http://www.php.net/manual/de/imagick.setresolution.php#85284
$svg = new \Imagick();
+ $svg->readImage($svgPath);
+ $res = $svg->getImageResolution();
+ $x_ratio = $res['x'] / $svg->getImageWidth();
+ $y_ratio = $res['y'] / $svg->getImageHeight();
+ $svg->removeImage();
+ $svg->setResolution($maxX * $x_ratio, $maxY * $y_ratio);
$svg->setBackgroundColor(new \ImagickPixel('transparent'));
$svg->readImage($svgPath);
$svg->setImageFormat('png32');