summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-08-18 17:33:05 +0200
committerGitHub <noreply@github.com>2021-08-18 17:33:05 +0200
commitbccdd32d4fe72024cfc0ccc8fe0d522e73a2ca01 (patch)
treea12916544181cb4bb2e682c07d3605ff4f3f5ca3 /lib/private
parent95987d903db987b138092f236c496752fe074cc6 (diff)
parent58f55975e068f156186c0a0930ab3dacc7e36c8c (diff)
downloadnextcloud-server-bccdd32d4fe72024cfc0ccc8fe0d522e73a2ca01.tar.gz
nextcloud-server-bccdd32d4fe72024cfc0ccc8fe0d522e73a2ca01.zip
Merge pull request #28485 from nextcloud/bugfix/20913/check-image-resource
Fix #20913: Check image resource before attempting to preserve alpha
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/legacy/OC_Image.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php
index 59d51773528..890df2241af 100644
--- a/lib/private/legacy/OC_Image.php
+++ b/lib/private/legacy/OC_Image.php
@@ -562,9 +562,13 @@ class OC_Image implements \OCP\IImage {
case IMAGETYPE_GIF:
if (imagetypes() & IMG_GIF) {
$this->resource = imagecreatefromgif($imagePath);
- // Preserve transparency
- imagealphablending($this->resource, true);
- imagesavealpha($this->resource, true);
+ if ($this->resource) {
+ // Preserve transparency
+ imagealphablending($this->resource, true);
+ imagesavealpha($this->resource, true);
+ } else {
+ $this->logger->debug('OC_Image->loadFromFile, GIF image not valid: ' . $imagePath, ['app' => 'core']);
+ }
} else {
$this->logger->debug('OC_Image->loadFromFile, GIF images not supported: ' . $imagePath, ['app' => 'core']);
}
@@ -583,9 +587,13 @@ class OC_Image implements \OCP\IImage {
case IMAGETYPE_PNG:
if (imagetypes() & IMG_PNG) {
$this->resource = @imagecreatefrompng($imagePath);
- // Preserve transparency
- imagealphablending($this->resource, true);
- imagesavealpha($this->resource, true);
+ if ($this->resource) {
+ // Preserve transparency
+ imagealphablending($this->resource, true);
+ imagesavealpha($this->resource, true);
+ } else {
+ $this->logger->debug('OC_Image->loadFromFile, PNG image not valid: ' . $imagePath, ['app' => 'core']);
+ }
} else {
$this->logger->debug('OC_Image->loadFromFile, PNG images not supported: ' . $imagePath, ['app' => 'core']);
}