diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-07-29 17:23:44 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-07-30 17:31:21 +0200 |
commit | 4f40cde66afe2376ede177020882e5236a5a3373 (patch) | |
tree | 2fa9ec2183b1a41b56cb77c9964c1b775b53d3c8 /lib | |
parent | 19bad71da2584450de3eed1e8f61337031a9466e (diff) | |
download | nextcloud-server-4f40cde66afe2376ede177020882e5236a5a3373.tar.gz nextcloud-server-4f40cde66afe2376ede177020882e5236a5a3373.zip |
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) { |