Hello, it seems that the SVG image processing in v13 is buggy.
In v12 the image is correct, with pencil and border. The other with only three horizontal lines are rendered from v13. Maybe the processing is only active at one path of the svg?
As I can overview there has nothing changed in our own templates or configs.
Start the commit message of your patch with this.
Add what the patch does, and the versions it goes to in "Releases:".
The changes above were merged or abandoned: read them before you start.
How to create a patch
Commit message
[BUGFIX] SVG image processing only one path
Resolves: #109681
Releases: main
This may be due to cropping, where SVG is done with some “inline” processing that wraps the SVG with an “outer” container that applies cropping. Can it be you’re using that? In v12 the image was probably rendered as PNG/GIF/JPG.
Can you investigate what the displayed SVG actually looks like in comparison to your original SVG?
Garvin Hicking wrote in #note-1: > This may be due to cropping, where SVG is done with some “inline” processing that wraps the SVG with an “outer” container that applies cropping. Can it be you’re using that? In v12 the image was probably rendered as PNG/GIF/JPG. > > Can you investigate what the displayed SVG actually looks like in comparison to your original SVG? > > Also see https://review.typo3.org/c/Packages/TYPO3.CMS/+/93664 for work in this area that might need to be backported to 13.4.
Yes it´s the cropping with ““. And the resulting image in “processed” is a webp-image.
Looked into this against current main (15.0-dev) and cross-checked 13.4, 14.3 and 12.4. I am fairly confident this is not a Core bug but the SVG renderer of the ImageMagick installation on the server.
The decisive detail is in note-3: the file in processed/ is a WebP. That means TYPO3’s own SVG handling is not involved at all.
Why: SvgImageProcessor::canProcessTask() only accepts a task whose target file extension is “svg” (SvgImageProcessor.php:51). As soon as the target extension is something else, the task goes to LocalImageProcessor -> GraphicalFunctions::resize() -> ImageMagick, and ImageMagickFile::resolvePrefix() maps image/svg+xml to the prefix “svg:” (ImageMagickFile.php:113-114). So ImageMagick receives “svg:/path/to/file.svg” and renders it with whatever SVG coder it has.
The target extension only becomes webp when configuration[‘fileExtension’] is set explicitly. That takes precedence over everything else in every version - 12.4, 13.4, 14.3 and main alike. Core itself never rasterizes an SVG: in 13.4 “svg” is in the pass-through list of ImageCropScaleMaskTask::determineTargetFileExtension(), and since v14 the default of GFX/imageFileConversionFormats contains ‘svg’ => ‘svg’. Setting fileExtension is what responsive-image extensions do when they build , so that is the most likely origin.
Reproduced the symptom without TYPO3, on a machine whose ImageMagick has no librsvg and no rsvg-convert binary:
Note “(XML …)” instead of “(RSVG …)” – that is ImageMagick’s own minimal renderer. delegates.xml does list svg => “rsvg-convert …”, but the binary was not installed, so the internal renderer takes over.
A test SVG with a stroked rectangle filled via fill=“url(#grad)”, a pencil referenced through <use xlink:href="#pencil" xmlns:xlink="http://www.w3.org/1999/xlink"> out of <defs>, plus a baseline<br>inside a <g>, rendered like this:</g></defs></use>
convert pencil.svg -resize 200×200 out.png
produced the pencil only. The frame, the gradient background and the baseline were silently dropped. That matches “in v12 the image is correct, with pencil and border” quite precisely. Even a simple SVG (one solid-colour <rect> plus two<br><path>s) did not come out correctly.</path></rect>
Two things I checked and can rule out on the Core side:
Crop geometry is not off. For an SVG with only viewBox=“0 0 940 724” and width=“100%”, identify reports the same 940×724 that TYPO3 derives from the viewBox, so crop coordinates and raster size line up.
The nested <svg><svg> that SvgImageProcessor produces when cropping is not the<br /> culprit either. identify does report the inner dimensions for it instead of<br /> the outer ones, but Core never reads them back that way:<br /> ImageInfo::getImageSizes() asks the XML parser first for image/svg+xml<br /> (extractSvgImageSizes(), root element = outer svg) and only falls back to<br /> ImageMagick. Same order in 13.4.</svg></svg>
For the record, https://review.typo3.org/c/Packages/TYPO3.CMS/+/93664 mentioned in note-1 has been abandoned. Its successor was merged as “[BUGFIX] Sanitize and size SVG via dedicated SvgDocument classes”, but that concerns sanitizing and dimension detection, not rasterization.
What would help to close this out:
1. The affected SVG attached to the ticket. 2. On the server: convert -list format | grep -i svg If it says “(XML …)” and rsvg-convert is missing, this is confirmed. 3. A check without TYPO3 in the loop: convert svg:original.svg out.png If that already looks wrong, TYPO3 is not the cause.
Two ways out, depending on what is wanted:
install librsvg2-bin (or an ImageMagick built with librsvg) – “svg:” then goes through rsvg-convert and the files render completely, or
do not rasterize the SVG at all: stop forcing fileExtension for SVG sources in the responsive-image configuration. From v14 on this can also be steered via GFX/imageFileConversionFormats.
One thing I could not explain from the Core code is the v12/v13 difference: fileExtension had the same precedence in 12.4, so ImageMagick did the rendering there as well. Garvin’s guess in note-1 that v12 rendered as PNG/GIF/JPG does not quite fit – it was rasterized in both cases. Knowing the TypoScript or the extension configuration used back then would settle that.
This may be due to cropping, where SVG is done with some “inline” processing that wraps the SVG with an “outer” container that applies cropping. Can it be you’re using that? In v12 the image was probably rendered as PNG/GIF/JPG.
Can you investigate what the displayed SVG actually looks like in comparison to your original SVG?
Also see https://review.typo3.org/c/Packages/TYPO3.CMS/+/93664 for work in this area that might need to be backported to 13.4.