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:
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) {