summaryrefslogtreecommitdiffstats
path: root/lib/private/preview/svg.php
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-06-06 16:21:36 +0200
committerOlivier Paroz <github@oparoz.com>2015-06-06 16:25:04 +0200
commit71d65cb713ebfb85ee19f9f3cd17dd915360fe9b (patch)
tree7281b8a32d148d27ae375dd1c45308416e63eee7 /lib/private/preview/svg.php
parent16708ae1873ddd563c3177b87cf7a4c395dca609 (diff)
downloadnextcloud-server-71d65cb713ebfb85ee19f9f3cd17dd915360fe9b.tar.gz
nextcloud-server-71d65cb713ebfb85ee19f9f3cd17dd915360fe9b.zip
Fix max preview, some resizing and caching issues and force preview providers to resize their previews properly
* introduces a method in OC_Image which doesn't stretch images when trying to make them fit in a box * adds the method to all key providers so that they can do their job, as expected by the Preview class * improves the caching mechanism of Preview in order to reduce I/O and to avoid filling the available disk space * fixes some long standing issues * **contains mostly tests**
Diffstat (limited to 'lib/private/preview/svg.php')
-rw-r--r--lib/private/preview/svg.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/private/preview/svg.php b/lib/private/preview/svg.php
index 7c74fb6fde2..92d21c07385 100644
--- a/lib/private/preview/svg.php
+++ b/lib/private/preview/svg.php
@@ -35,17 +35,17 @@ class SVG extends Provider {
* {@inheritDoc}
*/
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
- try{
+ try {
$svg = new \Imagick();
$svg->setBackgroundColor(new \ImagickPixel('transparent'));
$content = stream_get_contents($fileview->fopen($path, 'r'));
- if(substr($content, 0, 5) !== '<?xml') {
+ if (substr($content, 0, 5) !== '<?xml') {
$content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
}
// Do not parse SVG files with references
- if(stripos($content, 'xlink:href') !== false) {
+ if (stripos($content, 'xlink:href') !== false) {
return false;
}
@@ -60,6 +60,11 @@ class SVG extends Provider {
$image = new \OC_Image();
$image->loadFromData($svg);
//check if image object is valid
- return $image->valid() ? $image : false;
+ if ($image->valid()) {
+ $image->scaleDownToFit($maxX, $maxY);
+
+ return $image;
+ }
+ return false;
}
}