diff options
author | Morris Jobke <hey@morrisjobke.de> | 2014-07-30 17:22:20 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-07-30 17:22:20 +0200 |
commit | 62b37fbb997c0244d37953b05e333cdb2279a31a (patch) | |
tree | f51b0d3613ed361a65770a27b4284ac235268e30 /lib | |
parent | ef3c0c508fc18fc0888097f920883cda7c5e1370 (diff) | |
parent | c066320208da5211abe7e244bd2b045009367518 (diff) | |
download | nextcloud-server-62b37fbb997c0244d37953b05e333cdb2279a31a.tar.gz nextcloud-server-62b37fbb997c0244d37953b05e333cdb2279a31a.zip |
Merge pull request #10024 from owncloud/preview-restrict-height
Also keep maxY into account when scaling a preview while preserving aspect ratio
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/private/preview.php | 10 |
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) { |