diff options
Diffstat (limited to 'lib/private/image.php')
-rw-r--r-- | lib/private/image.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/private/image.php b/lib/private/image.php index d229ed42511..54e5ef7cad5 100644 --- a/lib/private/image.php +++ b/lib/private/image.php @@ -952,6 +952,8 @@ class OC_Image implements \OCP\IImage { /** * Resizes the image to fit within a boundary while preserving ratio. * + * Warning: Images smaller than $maxWidth x $maxHeight will end up being scaled up + * * @param integer $maxWidth * @param integer $maxHeight * @return bool @@ -973,6 +975,24 @@ class OC_Image implements \OCP\IImage { } /** + * Shrinks larger images to fit within specified boundaries while preserving ratio. + * + * @param integer $maxWidth + * @param integer $maxHeight + * @return bool + */ + public function scaleDownToFit($maxWidth, $maxHeight) { + $widthOrig = imageSX($this->resource); + $heightOrig = imageSY($this->resource); + + if ($widthOrig > $maxWidth || $heightOrig >$maxHeight) { + return $this->fitIn($maxWidth, $maxHeight); + } + + return false; + } + + /** * Destroys the current image and resets the object */ public function destroy() { |