Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-07-29 19:23:44 +0400
committerMorris Jobke <hey@morrisjobke.de>2014-07-30 19:31:21 +0400
commit4f40cde66afe2376ede177020882e5236a5a3373 (patch)
tree2fa9ec2183b1a41b56cb77c9964c1b775b53d3c8 /lib/private/preview.php
parent19bad71da2584450de3eed1e8f61337031a9466e (diff)
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) {