[BUGFIX] Try SVG first when detecting image size 21/56521/5
authorAnja <aleichsenring@ab-softlab.de>
Tue, 3 Apr 2018 14:56:50 +0000 (16:56 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Wed, 4 Apr 2018 11:37:11 +0000 (13:37 +0200)
By processing SVG files first and falling back to IM/GM identify, output
of a 'invalid image content' error for SVG files is avoided.

Change-Id: I44a7d822b100bdc83f7afa8aa544b6f3eff194d0
Resolves: #84586
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/56521
Reviewed-by: Stephan GroƟberndt <stephan.grossberndt@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/core/Classes/Type/File/ImageInfo.php

index c758f80..f94c97a 100644 (file)
@@ -60,16 +60,15 @@ class ImageInfo extends FileInfo implements LoggerAwareInterface
         if ($this->imageSizes === null) {
             $this->imageSizes = getimagesize($this->getPathname());
 
-            // Fallback to IM identify
+            // Try SVG first as SVG size detection with IM/GM leads to an error output
+            if ($this->imageSizes === false && $this->getMimeType() === 'image/svg+xml') {
+                $this->imageSizes = $this->extractSvgImageSizes();
+            }
+            // Fallback to IM/GM identify
             if ($this->imageSizes === false) {
                 $this->imageSizes = $this->getGraphicalFunctions()->imageMagickIdentify($this->getPathname());
             }
 
-            // Extra fallback for SVG
-            if (empty($this->imageSizes) && $this->getMimeType() === 'image/svg+xml') {
-                $this->imageSizes = $this->extractSvgImageSizes();
-            }
-
             // In case the image size could not be retrieved, log the incident as a warning.
             if (empty($this->imageSizes)) {
                 $this->logger->warning('I could not retrieve the image size for file ' . $this->getPathname());