Skip to content
Snippets Groups Projects
Commit 19ea4f79 authored by Thomas Müller's avatar Thomas Müller
Browse files

resize svg without loosing quality

parent be4aea2d
No related branches found
No related tags found
No related merge requests found
......@@ -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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment