diff --git a/lib/private/legacy/image.php b/lib/private/legacy/image.php
index d9af45f22262b740dfdc7d619e66abee4cace9ea..2efde2ee6885c60e3cb5db337259bc89e8fa94e3 100644
--- a/lib/private/legacy/image.php
+++ b/lib/private/legacy/image.php
@@ -878,10 +878,8 @@ class OC_Image implements \OCP\IImage {
 		$widthOrig = imagesx($this->resource);
 		$heightOrig = imagesy($this->resource);
 		$process = imagecreatetruecolor($width, $height);
-
-		if ($process == false) {
+		if ($process === false) {
 			$this->logger->error(__METHOD__ . '(): Error creating true color image', array('app' => 'core'));
-			imagedestroy($process);
 			return false;
 		}
 
@@ -892,8 +890,8 @@ class OC_Image implements \OCP\IImage {
 			imagesavealpha($process, true);
 		}
 
-		imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);
-		if ($process == false) {
+		$res = imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);
+		if ($res === false) {
 			$this->logger->error(__METHOD__ . '(): Error re-sampling process image', array('app' => 'core'));
 			imagedestroy($process);
 			return false;