summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-08-19 16:45:34 +0200
committerGitHub <noreply@github.com>2021-08-19 16:45:34 +0200
commit160dfbb78c3623b1e28707f336e7f4294b6c043b (patch)
treea9c0eafbc6d2d0a2235586a0a1146eb49b1191d0
parenta53e2809b4672b19fffd6a661691e8a13b1e2af6 (diff)
parentcb9e9f3026aa7b3110af678b28f7e4d86ef52a72 (diff)
downloadnextcloud-server-160dfbb78c3623b1e28707f336e7f4294b6c043b.tar.gz
nextcloud-server-160dfbb78c3623b1e28707f336e7f4294b6c043b.zip
Merge pull request #28498 from nextcloud/backport/28485/stable21
[stable21] Fix #20913: Check image resource before attempting to preserve alpha
-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 f1b9101045a..04a88106d92 100644
--- a/lib/private/legacy/OC_Image.php
+++ b/lib/private/legacy/OC_Image.php
@@ -563,9 +563,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']);
}
@@ -584,9 +588,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']);
}