‪TYPO3CMS  10.4
TYPO3\CMS\Frontend\Imaging\GifBuilder Class Reference
Inheritance diagram for TYPO3\CMS\Frontend\Imaging\GifBuilder:
TYPO3\CMS\Core\Imaging\GraphicalFunctions

Public Member Functions

 start ($conf, $data)
 
string gifBuild ()
 
 make ()
 
array checkTextObj ($conf)
 
string calcOffset ($string)
 
array null getResource ($file, $fileArray)
 
string null checkFile ($file)
 
string fileName ($pre)
 
string extension ()
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Imaging\GraphicalFunctions
 __construct ()
 
 maskImageOntoImage (&$im, $conf, $workArea)
 
 copyImageOntoImage (&$im, $conf, $workArea)
 
 copyGifOntoGif (&$im, $cpImg, $conf, $workArea)
 
 imagecopyresized (&$dstImg, $srcImg, $dstX, $dstY, $srcX, $srcY, $dstWidth, $dstHeight, $srcWidth, $srcHeight)
 
 makeText (&$im, $conf, $workArea)
 
array txtPosition ($conf, $workArea, $BB)
 
array calcBBox ($conf)
 
 addToMap ($cords, $conf)
 
array calcTextCordsForMap ($cords, $offset, $conf)
 
 SpacedImageTTFText (&$im, $fontSize, $angle, $x, $y, $Fcolor, $fontFile, $text, $spacing, $wordSpacing, $splitRenderingConf, $sF=1)
 
int fontResize ($conf)
 
array ImageTTFBBoxWrapper ($fontSize, $angle, $fontFile, $string, $splitRendering, $sF=1)
 
 ImageTTFTextWrapper ($im, $fontSize, $angle, $x, $y, $color, $fontFile, $string, $splitRendering, $sF=1)
 
array splitString ($string, $splitRendering, $fontSize, $fontFile)
 
array calcWordSpacing ($conf, $scaleFactor=1)
 
int getTextScalFactor ($conf)
 
 setImageFileExt (array $imageFileExt)
 
 makeOutline (&$im, $conf, $workArea, $txtConf)
 
array circleOffset ($distance, $iterations)
 
 makeEmboss (&$im, $conf, $workArea, $txtConf)
 
 makeShadow (&$im, $conf, $workArea, $txtConf)
 
 makeBox (&$im, $conf, $workArea)
 
 makeEllipse (&$im, array $conf, array $workArea)
 
 makeEffect (&$im, $conf)
 
string IMparams ($setup)
 
 adjust (&$im, $conf)
 
 crop (&$im, $conf)
 
 scale (&$im, $conf)
 
 setWorkArea ($workArea)
 
 autolevels (&$im)
 
 outputLevels (&$im, $low, $high, $swap=false)
 
 inputLevels (&$im, $low, $high)
 
string IMreduceColors ($file, $cols)
 
string v5_sharpen ($factor)
 
string v5_blur ($factor)
 
string randomName ()
 
array applyOffset ($cords, $OFFSET)
 
array convertColor ($string)
 
array objPosition ($conf, $workArea, $BB)
 
array null imageMagickConvert ($imagefile, $newExt='', $w='', $h='', $params='', $frame='', $options=[], $mustCreate=false)
 
array null getImageDimensions ($imageFile)
 
bool cacheImageDimensions (array $identifyResult)
 
array bool getCachedImageDimensions ($filePath)
 
array getImageScale ($info, $w, $h, $options)
 
array null imageMagickIdentify ($imagefile)
 
string imageMagickExec ($input, $output, $params, $frame=0)
 
string combineExec ($input, $overlay, $mask, $output)
 
 applyImageMagickToPHPGif (&$im, $command)
 
string gif_or_jpg ($type, $w, $h)
 
string output ($file)
 
 destroy ()
 
string imgTag ($imgInfo)
 
bool ImageWrite ($destImg, $theImage, $quality=0)
 
resource imageCreateFromFile ($sourceImg)
 
string hexColor ($color)
 
int unifyColors (&$img, $colArr, $closest=false)
 
 getTemporaryImageWithText ($filename, $textline1, $textline2, $textline3)
 

Public Attributes

array $combinedTextStrings = array( )
 
array $combinedFileNames = array( )
 
array $data = array( )
 
array $objBB = array( )
 
string $myClassName = 'gifbuilder'
 
array $charRangeMap = array( )
 
int[] $XY = array( )
 
ContentObjectRenderer $cObj
 
array $defaultWorkArea = array( )
 
- ‪Public Attributes inherited from ‪TYPO3\CMS\Core\Imaging\GraphicalFunctions
bool $addFrameSelection = true
 
string $gifExtension = 'gif'
 
int $truecolorColors = 16777215
 
array $cmds
 
string $filenamePrefix = ''
 
string $imageMagickConvert_forceFileNameBody = ''
 
bool $dontCheckForExistingTempFile = false
 
bool $dontCompress = false
 
string $alternativeOutputKey = ''
 
array $IM_commands = array( )
 
array $workArea = array( )
 
string $scalecmd = '-auto-orient -geometry'
 
string $map = ''
 
array $setup = array( )
 
int $w = 0
 
int $h = 0
 

Protected Member Functions

int calculateValue ($string)
 
string calculateFunctions ($string)
 
int calculateMaximum ($string)
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Core\Imaging\GraphicalFunctions
 renderTTFText (&$im, $fontSize, $angle, $x, $y, $color, $fontFile, $string, $splitRendering, $conf, $sF=1)
 
array getWordPairsForLineBreak ($string)
 
int getRenderedTextWidth ($text, $conf)
 
int getBreakSpace ($conf, array $boundingBox=null)
 
string generateCacheKeyForImageFile ($filePath)
 
string generateStatusHashForImageFile ($filePath)
 
string null executeIdentifyCommandForImageFile (string $imageFile)
 
float compensateFontSizeiBasedOnFreetypeDpi ($fontSize)
 

Additional Inherited Members

- ‪Static Public Member Functions inherited from ‪TYPO3\CMS\Core\Imaging\GraphicalFunctions
static string gifCompress ($theFile, $type)
 
static string null readPngGif ($theFile, $output_png=false)
 
- ‪Protected Attributes inherited from ‪TYPO3\CMS\Core\Imaging\GraphicalFunctions
array $gdlibExtensions = array( )
 
string $colorspace = 'RGB'
 
array $allowedColorSpaceNames
 
array $imageFileExt = array( 'gif', 'jpg', 'jpeg', 'png', 'tif', 'bmp', 'tga', 'pcx', 'ai', 'pdf' )
 
array $webImageExt = array( 'gif', 'jpg', 'jpeg', 'png' )
 
bool $processorEffectsEnabled = false
 
bool $processorEnabled
 
bool $mayScaleUp = true
 
bool $saveAlphaLayer = false
 
string $im5fx_blurSteps = '1x2,2x2,3x2,4x3,5x3,5x4,6x4,7x5,8x5,9x5'
 
string $im5fx_sharpenSteps = '1x2,2x2,3x2,2x3,3x3,4x3,3x4,4x4,4x5,5x5'
 
int $pixelLimitGif = 10000
 
array $colMap
 
CharsetConverter $csConvObj
 
int $jpegQuality = 85
 
array $OFFSET
 
resource $im
 

Detailed Description

GIFBUILDER

Generating gif/png-files from TypoScript Used by the menu-objects and imgResource in TypoScript.

This class allows for advanced rendering of images with various layers of images, text and graphical primitives. The concept is known from TypoScript as "GIFBUILDER" where you can define a "numerical array" (TypoScript term as well) of "GIFBUILDER OBJECTS" (like "TEXT", "IMAGE", etc.) and they will be rendered onto an image one by one. The name "GIFBUILDER" comes from the time where GIF was the only file format supported. PNG is just as well to create today (configured with TYPO3_CONF_VARS[GFX]) Not all instances of this class is truly building gif/png files by layers; You may also see the class instantiated for the purpose of using the scaling functions in the parent class.

Here is an example of how to use this class (from tslib_content.php, function getImgResource):

$gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class); $gifCreator->init(); $theImage=''; if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) { $gifCreator->start($fileArray, $this->data); $theImage = $gifCreator->gifBuild(); } return $gifCreator->getImageDimensions($theImage);

Definition at line 55 of file GifBuilder.php.

Member Function Documentation

◆ calcOffset()

string TYPO3\CMS\Frontend\Imaging\GifBuilder::calcOffset (   $string)

Calculation of offset using "splitCalc" and insertion of dimensions from other GIFBUILDER objects.

Example: Input: 2+2, 2*3, 123, [10.w] Output: 4,6,123,45 (provided that the width of object in position 10 was 45 pixels wide)

Parameters
string$string‪The string to resolve/calculate the result of. The string is divided by a comma first and each resulting part is calculated into an integer.
Returns
‪string The resolved string with each part (separated by comma) returned separated by comma

Definition at line 650 of file GifBuilder.php.

References TYPO3\CMS\Frontend\Imaging\GifBuilder\calculateFunctions(), TYPO3\CMS\Frontend\Imaging\GifBuilder\calculateValue(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\calculateMaximum(), and TYPO3\CMS\Frontend\Imaging\GifBuilder\start().

◆ calculateFunctions()

string TYPO3\CMS\Frontend\Imaging\GifBuilder::calculateFunctions (   $string)
protected

Calculates special functions:

  • ‪max([10.h], [20.h]) -> gets the maximum of the given values
Parameters
string$string‪The raw string with functions to be calculated
Returns
‪string The calculated values

Definition at line 822 of file GifBuilder.php.

References TYPO3\CMS\Frontend\Imaging\GifBuilder\calculateMaximum().

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\calcOffset().

◆ calculateMaximum()

int TYPO3\CMS\Frontend\Imaging\GifBuilder::calculateMaximum (   $string)
protected

Calculates the maximum of a set of values defined like "[10.h],[20.h],1000"

Parameters
string$string‪The string to be used to calculate the maximum (e.g. "[10.h],[20.h],1000")
Returns
‪int The maximum value of the given comma separated and calculated values

Definition at line 838 of file GifBuilder.php.

References TYPO3\CMS\Frontend\Imaging\GifBuilder\calcOffset(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\calculateFunctions().

◆ calculateValue()

int TYPO3\CMS\Frontend\Imaging\GifBuilder::calculateValue (   $string)
protected

Calculates the value concerning the dimensions of objects.

Parameters
string$string‪The string to be calculated (e.g. "[20.h]+13")
Returns
‪int The calculated value (e.g. "23")
See also
calcOffset()

Definition at line 773 of file GifBuilder.php.

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\calcOffset().

◆ checkFile()

string null TYPO3\CMS\Frontend\Imaging\GifBuilder::checkFile (   $file)

Returns the reference to a "resource" in TypoScript.

Parameters
string$file‪The resource value.
Returns
‪string|null Returns the relative filepath or null if it's invalid
See also
‪TemplateService::getFileName()

Definition at line 700 of file GifBuilder.php.

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\checkTextObj().

◆ checkTextObj()

array TYPO3\CMS\Frontend\Imaging\GifBuilder::checkTextObj (   $conf)

Initializing/Cleaning of TypoScript properties for TEXT GIFBUILDER objects

'cleans' TEXT-object; Checks fontfile and other vital setup Finds the title if its a 'variable' (instantiates a cObj and loads it with the ->data record) Performs caseshift if any.

Parameters
array$conf‪GIFBUILDER object TypoScript properties
Returns
‪array Modified $conf array IF the "text" property is not blank

Definition at line 553 of file GifBuilder.php.

References TYPO3\CMS\Frontend\Imaging\GifBuilder\$cObj, TYPO3\CMS\Core\Utility\PathUtility\basename(), TYPO3\CMS\Frontend\Imaging\GifBuilder\checkFile(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\start(), and TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\stdWrap().

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\make(), and TYPO3\CMS\Frontend\Imaging\GifBuilder\start().

◆ extension()

string TYPO3\CMS\Frontend\Imaging\GifBuilder::extension ( )

Returns the file extension used in the filename

Returns
‪string Extension; "jpg" or "gif"/"png

Definition at line 751 of file GifBuilder.php.

References TYPO3\CMS\Core\Imaging\GraphicalFunctions\$gifExtension.

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\fileName().

◆ fileName()

string TYPO3\CMS\Frontend\Imaging\GifBuilder::fileName (   $pre)

Calculates the GIFBUILDER output filename/path based on a serialized, hashed value of this->setup and prefixes the original filename also, the filename gets an additional prefix (max 100 characters), something like "GB_MD5HASH_myfilename_is_very_long_and_such.jpg"

Parameters
string$pre‪Filename prefix, eg. "GB_
Returns
‪string The filepath, relative to Environment::getPublicPath()

Definition at line 719 of file GifBuilder.php.

References TYPO3\CMS\Frontend\Imaging\GifBuilder\$combinedFileNames, TYPO3\CMS\Frontend\Imaging\GifBuilder\$combinedTextStrings, TYPO3\CMS\Frontend\Imaging\GifBuilder\$data, TYPO3\CMS\Core\Imaging\GraphicalFunctions\$h, TYPO3\CMS\Core\Imaging\GraphicalFunctions\$im, TYPO3\CMS\Core\Imaging\GraphicalFunctions\$map, TYPO3\CMS\Core\Imaging\GraphicalFunctions\$w, TYPO3\CMS\Core\Imaging\GraphicalFunctions\$workArea, and TYPO3\CMS\Frontend\Imaging\GifBuilder\extension().

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\gifBuild().

◆ getResource()

array null TYPO3\CMS\Frontend\Imaging\GifBuilder::getResource (   $file,
  $fileArray 
)

Returns an "imgResource" creating an instance of the ContentObjectRenderer class and calling ContentObjectRenderer::getImgResource

Parameters
string$file‪Filename value OR the string "GIFBUILDER", see documentation in TSref for the "datatype" called "imgResource @param array $fileArray TypoScript properties passed to the function. Either GIFBUILDER properties or imgResource properties, depending on the value of $file (whether that is "GIFBUILDER" or a file reference)
Returns
‪array|null Returns an array with file information from ContentObjectRenderer::getImgResource()
See also
ContentObjectRenderer::getImgResource()

Definition at line 674 of file GifBuilder.php.

References TYPO3\CMS\Frontend\Imaging\GifBuilder\$cObj, TYPO3\CMS\Core\Imaging\GraphicalFunctions\$gifExtension, TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\getImgResource(), and TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\start().

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\start().

◆ gifBuild()

string TYPO3\CMS\Frontend\Imaging\GifBuilder::gifBuild ( )

Initiates the image file generation if ->setup is TRUE and if the file did not exist already. Gets filename from fileName() and if file exists in typo3temp/assets/images/ dir it will - of course - not be rendered again. Otherwise rendering means calling ->make(), then ->output(), then ->destroy()

Returns
‪string The filename for the created GIF/PNG file. The filename will be prefixed "GB_
See also
make()
fileName()

Definition at line 345 of file GifBuilder.php.

References TYPO3\CMS\Core\Imaging\GraphicalFunctions\destroy(), TYPO3\CMS\Frontend\Imaging\GifBuilder\fileName(), TYPO3\CMS\Core\Core\Environment\getPublicPath(), TYPO3\CMS\Frontend\Imaging\GifBuilder\make(), TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep(), and TYPO3\CMS\Core\Imaging\GraphicalFunctions\output().

◆ make()

TYPO3\CMS\Frontend\Imaging\GifBuilder::make ( )

The actual rendering of the image file. Basically sets the dimensions, the background color, the traverses the array of GIFBUILDER objects and finally setting the transparent color if defined. Creates a GDlib resource in $this->im and works on that Called by gifBuild()

See also
gifBuild()

Definition at line 373 of file GifBuilder.php.

References TYPO3\CMS\Frontend\Imaging\GifBuilder\$defaultWorkArea, TYPO3\CMS\Core\Imaging\GraphicalFunctions\$im, TYPO3\CMS\Frontend\Imaging\GifBuilder\$XY, TYPO3\CMS\Core\Imaging\GraphicalFunctions\adjust(), TYPO3\CMS\Frontend\Imaging\GifBuilder\checkTextObj(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\convertColor(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\copyImageOntoImage(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\crop(), TYPO3\CMS\Core\Utility\ArrayUtility\filterAndSortByNumericKeys(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeBox(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeEffect(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeEllipse(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeEmboss(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeOutline(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeShadow(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeText(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\maskImageOntoImage(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\scale(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\setWorkArea(), and TYPO3\CMS\Core\Imaging\GraphicalFunctions\unifyColors().

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\gifBuild().

◆ start()

TYPO3\CMS\Frontend\Imaging\GifBuilder::start (   $conf,
  $data 
)

Initialization of the GIFBUILDER objects, in particular TEXT and IMAGE. This includes finding the bounding box, setting dimensions and offset values before the actual rendering is started. Modifies the ->setup, ->objBB internal arrays Should be called after the ->init() function which initializes the parent class functions/variables in general.

Parameters
array$conf‪TypoScript properties for the GIFBUILDER session. Stored internally in the variable ->setup
array$data‪The current data record from \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer. Stored internally in the variable ->data
See also
ContentObjectRenderer::getImgResource()

Definition at line 108 of file GifBuilder.php.

References TYPO3\CMS\Frontend\Imaging\GifBuilder\$cObj, TYPO3\CMS\Frontend\Imaging\GifBuilder\$data, $GLOBALS, TYPO3\CMS\Core\Imaging\GraphicalFunctions\$setup, TYPO3\CMS\Core\Imaging\GraphicalFunctions\$workArea, TYPO3\CMS\Frontend\Imaging\GifBuilder\$XY, TYPO3\CMS\Core\Utility\PathUtility\basename(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\calcBBox(), TYPO3\CMS\Frontend\Imaging\GifBuilder\calcOffset(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\checkIf(), TYPO3\CMS\Frontend\Imaging\GifBuilder\checkTextObj(), TYPO3\CMS\Core\Utility\ArrayUtility\filterAndSortByNumericKeys(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\fontResize(), TYPO3\CMS\Core\Utility\MathUtility\forceIntegerInRange(), TYPO3\CMS\Frontend\Imaging\GifBuilder\getResource(), TYPO3\CMS\Core\Utility\GeneralUtility\intExplode(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\setWorkArea(), and TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\start().

Member Data Documentation

◆ $charRangeMap

array TYPO3\CMS\Frontend\Imaging\GifBuilder::$charRangeMap = array( )

Definition at line 85 of file GifBuilder.php.

◆ $cObj

◆ $combinedFileNames

array TYPO3\CMS\Frontend\Imaging\GifBuilder::$combinedFileNames = array( )

Contains all filenames (basename without extension) used on this image

Definition at line 67 of file GifBuilder.php.

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\fileName().

◆ $combinedTextStrings

array TYPO3\CMS\Frontend\Imaging\GifBuilder::$combinedTextStrings = array( )

Contains all text strings used on this image

Definition at line 61 of file GifBuilder.php.

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\fileName().

◆ $data

array TYPO3\CMS\Frontend\Imaging\GifBuilder::$data = array( )

This is the array from which data->field: [key] is fetched. So this is the current record!

Definition at line 73 of file GifBuilder.php.

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\fileName(), and TYPO3\CMS\Frontend\Imaging\GifBuilder\start().

◆ $defaultWorkArea

array TYPO3\CMS\Frontend\Imaging\GifBuilder::$defaultWorkArea = array( )

Definition at line 97 of file GifBuilder.php.

Referenced by TYPO3\CMS\Frontend\Imaging\GifBuilder\make().

◆ $myClassName

string TYPO3\CMS\Frontend\Imaging\GifBuilder::$myClassName = 'gifbuilder'

Definition at line 81 of file GifBuilder.php.

◆ $objBB

array TYPO3\CMS\Frontend\Imaging\GifBuilder::$objBB = array( )

Definition at line 77 of file GifBuilder.php.

◆ $XY

int [] TYPO3\CMS\Frontend\Imaging\GifBuilder::$XY = array( )