summaryrefslogtreecommitdiffstats
path: root/lib/private/preview.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-07-29 17:23:44 +0200
committerMorris Jobke <hey@morrisjobke.de>2014-07-30 13:52:40 +0200
commitc066320208da5211abe7e244bd2b045009367518 (patch)
tree908b5f6aee85d8313b077f550cb809fdab6400df /lib/private/preview.php
parent06d118d06c0def5a33aab64c6a2c20f79944b378 (diff)
downloadnextcloud-server-c066320208da5211abe7e244bd2b045009367518.tar.gz
nextcloud-server-c066320208da5211abe7e244bd2b045009367518.zip
Also keep maxY into account when scaling a preview while preserving aspect ratio
Diffstat (limited to 'lib/private/preview.php')
-rwxr-xr-xlib/private/preview.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/private/preview.php b/lib/private/preview.php
index 8089379bde5..6172519c7d1 100755
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -561,9 +561,15 @@ class Preview {
$realX = (int)$image->width();
$realY = (int)$image->height();
- // compute $maxY using the aspect of the generated preview
+ // compute $maxY and $maxX using the aspect of the generated preview
if ($this->keepAspect) {
- $y = $x / ($realX / $realY);
+ $ratio = $realX / $realY;
+ if($x / $ratio < $y) {
+ // width restricted
+ $y = $x / $ratio;
+ } else {
+ $x = $y * $ratio;
+ }
}
if ($x === $realX && $y === $realY) {