diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
index 167b4334fb43a628ac4e21ba6d05219236d27328..a28c8889a87c77a9b32e6fcb8d8efe86a272c557 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
@@ -4151,10 +4151,12 @@ class ContentObjectRenderer implements LoggerAwareInterface
             try {
                 $theImage = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($file);
                 $info = GeneralUtility::makeInstance(GifBuilder::class)->imageMagickConvert($theImage, 'WEB');
-                $info['origFile'] = $theImage;
-                // This is needed by \TYPO3\CMS\Frontend\Imaging\GifBuilder, ln 100ff in order for the setup-array to create a unique filename hash.
-                $info['origFile_mtime'] = @filemtime($theImage);
-                $imageResource = $info;
+                if ($info !== null) {
+                    $info['origFile'] = $theImage;
+                    // This is needed by \TYPO3\CMS\Frontend\Imaging\GifBuilder, ln 100ff in order for the setup-array to create a unique filename hash.
+                    $info['origFile_mtime'] = @filemtime($theImage);
+                    $imageResource = $info;
+                }
             } catch (Exception $e) {
                 // do nothing in case the file path is invalid
             }