Feature #75191

Converting svg to png not possible without cropping or masking the image

Added by christian rauch almost 4 years ago. Updated almost 2 years ago.

Should have
Image Generation / GIFBUILDER
Target version:
Start date:
Due date:
% Done:


PHP Version:
Sprint Focus:


I tried to write a viewhelper which generates a Fallback Png for SVG Images. I added 'fileExtension' => 'png' to the processing Instructions but it gets ignored because of the following condition in LocalCropScaleMaskHelper.php

            // SVG
            if ($croppedImage === null && $sourceFile->getExtension() === 'svg') {
                $newDimensions = $this->getNewSvgDimensions($sourceFile, $configuration, $options, $gifBuilder);
                $result = array(
                    0 => $newDimensions['width'],
                    1 => $newDimensions['height'],
                    3 => '' // no file = use original

            // all other images

First I thought about extending the condition like that

 if ($croppedImage === null && $sourceFile->getExtension() === 'svg' && $configuration['fileExtension'] !=='svg') {

But this will always be true as the fileExtension will be one of gif, jpg, or png if not explicitly set...

Would it be possible to add an extra configuration parameter like forceSvgConvert or something like that

The condition could then look like this

 if ($croppedImage === null && $sourceFile->getExtension() === 'svg' && !$configuration['forceSvgConvert']) {

And one could use processing Instructions like this to force the generation of a Fallback Png for a svg image

$processingInstructions = array(
  'width' => $width,
  'height' => $height,
  'minWidth' => $minWidth,
  'minHeight' => $minHeight,
  'maxWidth' => $maxWidth,
  'maxHeight' => $maxHeight,
  'additionalParameters' => ' -background none',
  'fileExtension' => 'png',
  'forceSvgConvert' => true


#1 Updated by christian rauch almost 4 years ago

  • Assignee set to Frans Saris

#2 Updated by Frans Saris almost 4 years ago

Out of curiosity, what's your use-case to convert svg to PNG?

#3 Updated by christian rauch almost 4 years ago

I want our Editors to upload Icons for a Product Detail Page in Svg Format but this Website still has to work on IE8 (yay!) and therefore I need a png Fallback. I could of course add a second File Reference and have them upload the same Icon in PNG Format but I thought that I can do this on the Server.

I already tried a fake crop and a fake mask. The Icon then is converted to png but somehow it's rendered horribly.

#4 Updated by Frans Saris almost 4 years ago

But you tested it without crop and the quality is then okay?

If we add such a config option to core it will only be for master (TYPO3 8), not for 7 as we don't backport features to stable releases.

#5 Updated by christian rauch almost 4 years ago

Yes, then the quality is good...

I know IE8 is a legacy Browser and supporting it becomes less and less critical but I could imagine that Typo3 is also used to generate Content for other Systems that don't support svgs. Maybe Word Documents or something like that.

For now I'll help myself with an Xclass as we have to use the LTS Version and still have a bunch of huge pibase Extensions which we didn't port to extbase.

Also I didn't dig to deep into the quality issues with the mask and crop workaround.

#6 Updated by Oliver Hader over 3 years ago

  • Tracker changed from Bug to Feature
  • Complexity changed from easy to medium

#7 Updated by Frans Saris over 3 years ago

  • Assignee deleted (Frans Saris)

#8 Updated by Markus Hölzle almost 3 years ago

Hey there,
can we think about this issue again?
It is still impossible to convert SVG graphics to PNG images.
But for example big and complex SVG graphics make the iPhone to crash... So we just need a PNG fallback for modern browsers.
Any chance to get this into the core?

#9 Updated by Riccardo De Contardi almost 2 years ago

  • Category set to Image Generation / GIFBUILDER

Also available in: Atom PDF