Skip to content
Snippets Groups Projects
Commit 8f8adb7e authored by Anja's avatar Anja Committed by Georg Ringer
Browse files

[BUGFIX] Try SVG first when detecting image size

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: default avatarStephan Großberndt <stephan.grossberndt@typo3.org>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarFrans Saris <franssaris@gmail.com>
Tested-by: default avatarFrans Saris <franssaris@gmail.com>
Reviewed-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
parent b4de256c
No related merge requests found
......@@ -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());
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment