@@ -563,9 +563,13 @@ public function loadFromFile($imagePath = false) {
563563 case IMAGETYPE_GIF :
564564 if (imagetypes () & IMG_GIF ) {
565565 $ this ->resource = imagecreatefromgif ($ imagePath );
566- // Preserve transparency
567- imagealphablending ($ this ->resource , true );
568- imagesavealpha ($ this ->resource , true );
566+ if ($ this ->resource ) {
567+ // Preserve transparency
568+ imagealphablending ($ this ->resource , true );
569+ imagesavealpha ($ this ->resource , true );
570+ } else {
571+ $ this ->logger ->debug ('OC_Image->loadFromFile, GIF image not valid: ' . $ imagePath , ['app ' => 'core ' ]);
572+ }
569573 } else {
570574 $ this ->logger ->debug ('OC_Image->loadFromFile, GIF images not supported: ' . $ imagePath , ['app ' => 'core ' ]);
571575 }
@@ -584,9 +588,13 @@ public function loadFromFile($imagePath = false) {
584588 case IMAGETYPE_PNG :
585589 if (imagetypes () & IMG_PNG ) {
586590 $ this ->resource = @imagecreatefrompng ($ imagePath );
587- // Preserve transparency
588- imagealphablending ($ this ->resource , true );
589- imagesavealpha ($ this ->resource , true );
591+ if ($ this ->resource ) {
592+ // Preserve transparency
593+ imagealphablending ($ this ->resource , true );
594+ imagesavealpha ($ this ->resource , true );
595+ } else {
596+ $ this ->logger ->debug ('OC_Image->loadFromFile, PNG image not valid: ' . $ imagePath , ['app ' => 'core ' ]);
597+ }
590598 } else {
591599 $ this ->logger ->debug ('OC_Image->loadFromFile, PNG images not supported: ' . $ imagePath , ['app ' => 'core ' ]);
592600 }
0 commit comments