Make sure we have a resource before measuring its size

This commit is contained in:
Olivier Paroz 2015-06-08 15:10:29 +02:00
parent 71d65cb713
commit 3d0a523217
1 changed files with 5 additions and 1 deletions

View File

@ -982,10 +982,14 @@ class OC_Image implements \OCP\IImage {
* @return bool
*/
public function scaleDownToFit($maxWidth, $maxHeight) {
if (!$this->valid()) {
$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
return false;
}
$widthOrig = imageSX($this->resource);
$heightOrig = imageSY($this->resource);
if ($widthOrig > $maxWidth || $heightOrig >$maxHeight) {
if ($widthOrig > $maxWidth || $heightOrig > $maxHeight) {
return $this->fitIn($maxWidth, $maxHeight);
}