From 19ea4f79da63f640678c7eae0511f342ea2474b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= <thomas.mueller@tmit.eu> Date: Fri, 11 Oct 2013 00:12:37 +0200 Subject: [PATCH] resize svg without loosing quality --- lib/private/preview/unknown.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/private/preview/unknown.php b/lib/private/preview/unknown.php index 62444ac6a2..4747f9e25e 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'); -- GitLab