‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Imaging\SvgManipulation Class Reference

Public Member Functions

 cropScaleSvgString (string $svgString, Area $cropArea, ImageDimension $imageDimension)
 

Protected Member Functions

 adjustSvgDimensions (\DOMDocument $originalSvg, array $determinedDimensions)
 
 determineSvgDimensions (\DOMDocument $originalSvg)
 

Private Attributes

int $defaultSvgDimension = 64
 

Detailed Description

Performs SVG cropping by applying a wrapper SVG as view

A simple SVG with an input like this:

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 168.4 940.7 724" width="941" height="724"> <path id="path" d="M490.1 655.5c-9.4 1.2-16.9 </svg>

is wrapped with crop dimensions (i.e. "50 50 640 480") to something like this:

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="50 50 640 480" width="640" height="480"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 168.4 940.7 724" width="941" height="724"> <path id="path" d="M490.1 655.5c-9.4 1.2-16.9 </svg> </svg>

not part of TYPO3 Core API.

Definition at line 43 of file SvgManipulation.php.

Member Function Documentation

◆ adjustSvgDimensions()

TYPO3\CMS\Core\Imaging\SvgManipulation::adjustSvgDimensions ( \DOMDocument  $originalSvg,
array  $determinedDimensions 
)
protected

Ensure that the determined width and height settings are attributes on the original <svg>. If those were missing, cropping could not successfully be applied when getting embedded and adjusted within a element.

Returns true, if the determined width/height has been injected into the main <svg>

Definition at line 108 of file SvgManipulation.php.

Referenced by TYPO3\CMS\Core\Imaging\SvgManipulation\cropScaleSvgString().

◆ cropScaleSvgString()

◆ determineSvgDimensions()

TYPO3\CMS\Core\Imaging\SvgManipulation::determineSvgDimensions ( \DOMDocument  $originalSvg)
protected

Check an input SVG element for its dimensions through width/height/viewBox attributes.

Returns an array with the determined width/height.

Definition at line 133 of file SvgManipulation.php.

References TYPO3\CMS\Core\Imaging\SvgManipulation\$defaultSvgDimension.

Referenced by TYPO3\CMS\Core\Imaging\SvgManipulation\cropScaleSvgString().

Member Data Documentation

◆ $defaultSvgDimension

int TYPO3\CMS\Core\Imaging\SvgManipulation::$defaultSvgDimension = 64
private