From 2c1e9b92eb88661606f8e20fa4ee6a7a61df74a0 Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Fri, 2 Oct 2020 20:58:14 +0000
Subject: [PATCH] Fix fatal error: Uncaught ImagickException: cache resources
 exhausted

---
 src/Object/Image.php | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/Object/Image.php b/src/Object/Image.php
index b69682ca61..d69b01ad4d 100644
--- a/src/Object/Image.php
+++ b/src/Object/Image.php
@@ -22,7 +22,6 @@
 namespace Friendica\Object;
 
 use Exception;
-use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Util\Images;
 use Imagick;
@@ -123,7 +122,11 @@ class Image
 			$this->image->setFormat($format);
 
 			// Always coalesce, if it is not a multi-frame image it won't hurt anyway
-			$this->image = $this->image->coalesceImages();
+			try {
+				$this->image = $this->image->coalesceImages();
+			} catch (Exception $e) {
+				return false;
+			}
 
 			/*
 			 * setup the compression here, so we'll do it only once