GifBuilder
GIFBUILDER
Generating image files from TypoScript Used by 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 when GIF was the only file format supported. .png, .jpg, .webp and .avif files are just as well to create today (configured with TYPO3_CONF_VARS[GFX])
Here is an example of how to use this class:
$imageCreator = GeneralUtility::makeInstance(GifBuilder::class); $imageCreator->start($fileArray, $this->data); $theImage = $imageCreator->gifBuild();
Table of Contents
Properties
- $setup : array<string|int, mixed>
- This holds the operational setup.
- $avifQuality : int<-1, 100>
- $charRangeMap : array<string, array<string|int, mixed>>
- $cObj : ContentObjectRenderer|null
- $colMap : array<non-empty-string, array{0: int<0, 255>, 1: int<0, 255>, 2: int<0, 255>}>
- Array mapping HTML color names to RGB values.
- $combinedFileNames : array<int, string>
- Contains all filenames (basename without extension) used on this image
- $combinedTextStrings : array<int, string>
- Contains all text strings used on this image
- $csConvObj : CharsetConverter
- $data : array<string|int, mixed>
- This is the array from which data->field: [key] is fetched. So this is the current record!
- $defaultWorkArea : array<int, int>
- $h : int<0, max>
- $jpegQuality : int<10, 100>
- $objBB : array<string|int, mixed>
- $offset : array<int, int>
- $saveAlphaLayer : bool
- Preserve the alpha transparency layer of read PNG images
- $w : int<0, max>
- $webpQuality : int<10, 101>
- $workArea : array<int, int>
- $XY : array{0?: int<0, max>, 1?: int<0, max>}
Methods
- __construct() : mixed
- calcBBox() : array<string|int, mixed>
- Calculates bounding box information for the TEXT GIFBUILDER object.
- calcOffset() : string
- Calculation of offset using "splitCalc" and insertion of dimensions from other GIFBUILDER objects.
- gifBuild() : ImageResource|null
- 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 destroys the image and returns the ImageResource DTO.
- imageCreateFromFile() : GdImage|false
- Creates a new GDlib image resource based on the input image filename.
- ImageWrite() : bool
- Writes the input GDlib image pointer to file
- makeBox() : void
- Implements the "BOX" GIFBUILDER object
- makeEllipse() : void
- Implements the "Ellipse" GIFBUILDER object Example Typoscript: file = GIFBUILDER file { XY = 200,200 format = jpg quality = 100 10 = ELLIPSE 10.dimensions = 100,100,50,50 10.color = red
- makeShadow() : void
- Implements the "SHADOW" GIFBUILDER object / property for the TEXT object The blurred shadow is composited through an in-memory mask.
- makeText() : void
- Implements the "TEXT" GIFBUILDER object
- start() : void
- 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.
- adjust() : void
- Implements the "ADJUST" GIFBUILDER object
- applyOffset() : array<string|int, mixed>
- Applies offset value to coordinated in $cords.
- calculateFunctions() : string
- Calculates special functions: + max([10.h], [20.h]) -> gets the maximum of the given values
- calculateMaximum() : int
- Calculates the maximum of a set of values defined like "[10.h],[20.h],1000"
- calculateValue() : int
- Calculates the value concerning the dimensions of objects.
- calcWordSpacing() : array<string|int, mixed>
- Calculates the spacing and wordSpacing values
- checkTextObj() : array<string|int, mixed>|null
- Initializing/Cleaning of TypoScript properties for TEXT GIFBUILDER objects
- circleOffset() : array<string|int, mixed>
- Creates some offset values in an array used to simulate a circularly applied outline around TEXT
- compensateFontSizeiBasedOnFreetypeDpi() : float
- Function to compensate for DPI resolution.
- convertColor() : array<string|int, mixed>
- Converts a "HTML-color" TypoScript datatype to RGB-values.
- copyGifOntoGif() : void
- Copies two GDlib image pointers onto each other, using TypoScript configuration from $conf and the input $workArea definition.
- copyImageOntoImage() : void
- Implements the "IMAGE" GIFBUILDER object, when the "mask" property is FALSE (using only $conf['file'])
- crop() : void
- Implements the "CROP" GIFBUILDER object
- extension() : string
- Returns the file extension used in the filename
- fileName() : string
- Calculates the GIFBUILDER output filename based on a serialized, hashed value of this->setup and prefixes the original filename.
- fontResize() : int
- Function that finds the right fontsize that will render the textstring within a certain width
- getBreakSpace() : int
- Gets the break space for each new line.
- getRenderedTextWidth() : int
- Gets the rendered text width
- getResource() : ImageResource|null
- Returns an "imgResource" creating an instance of the ContentObjectRenderer class and calling ContentObjectRenderer::getImgResource
- getTextScalFactor() : int
- Calculates and returns the niceText.scaleFactor
- getWordPairsForLineBreak() : array<string|int, mixed>
- Gets the word pairs used for automatic line breaks.
- hexColor() : string
- Returns the HEX color value for an RGB color array
- imagecopyresized() : GdImage
- Alternative function for using the similar PHP function imagecopyresized(). Used for GD2 only.
- ImageTTFBBoxWrapper() : array<string|int, mixed>
- Wrapper for ImageTTFBBox
- ImageTTFTextWrapper() : void
- Wrapper for ImageTTFText
- make() : GdImage
- The actual rendering of the image file.
- makeEffect() : void
- Implements the "EFFECT" GIFBUILDER object.
- makeEmboss() : void
- Implements the "EMBOSS" GIFBUILDER object / property for the TEXT object
- makeOutline() : void
- Implements the "OUTLINE" GIFBUILDER object / property for the TEXT object
- maskImageOntoImage() : void
- Implements the "IMAGE" GIFBUILDER object, when the "mask" property is TRUE.
- objPosition() : array<string|int, mixed>
- Create an array with object position/boundaries based on input TypoScript configuration (such as the "align" property is used), the work area definition and $BB array
- output() : void
- Writing the image pointer, to file based on the extension of the input filename.
- renderTTFText() : void
- Renders a regular text and takes care of a possible line break automatically.
- scale() : void
- Implements the "SCALE" GIFBUILDER object
- setWorkArea() : void
- Implements the "WORKAREA" GIFBUILDER object when setting it Setting internal working area boundaries (->workArea)
- SpacedImageTTFText() : void
- Printing text onto an image like the PHP function imageTTFText does but in addition it offers options for spacing of letters and words.
- splitString() : array<string|int, mixed>
- Splitting a string for ImageTTFBBox up into an array where each part has its own configuration options.
- txtPosition() : array<string|int, mixed>
- Calculates text position for printing the text onto the image based on configuration like alignment and workarea.
- unifyColors() : int
- Unifies all colors given in the colArr color array to the first color in the array.
Properties
$setup
This holds the operational setup.
public
array<string|int, mixed>
$setup
= []
Basically this is a TypoScript array with properties.
$avifQuality
protected
int<-1, 100>
$avifQuality
= 85
$charRangeMap
protected
array<string, array<string|int, mixed>>
$charRangeMap
= []
$cObj
protected
ContentObjectRenderer|null
$cObj
= null
$colMap
Array mapping HTML color names to RGB values.
protected
array<non-empty-string, array{0: int<0, 255>, 1: int<0, 255>, 2: int<0, 255>}>
$colMap
= ['aqua' => [0, 255, 255], 'black' => [0, 0, 0], 'blue' => [0, 0, 255], 'fuchsia' => [255, 0, 255], 'gray' => [128, 128, 128], 'green' => [0, 128, 0], 'lime' => [0, 255, 0], 'maroon' => [128, 0, 0], 'navy' => [0, 0, 128], 'olive' => [128, 128, 0], 'purple' => [128, 0, 128], 'red' => [255, 0, 0], 'silver' => [192, 192, 192], 'teal' => [0, 128, 128], 'yellow' => [255, 255, 0], 'white' => [255, 255, 255]]
$combinedFileNames
Contains all filenames (basename without extension) used on this image
protected
array<int, string>
$combinedFileNames
= []
$combinedTextStrings
Contains all text strings used on this image
protected
array<int, string>
$combinedTextStrings
= []
$csConvObj
protected
CharsetConverter
$csConvObj
$data
This is the array from which data->field: [key] is fetched. So this is the current record!
protected
array<string|int, mixed>
$data
= []
$defaultWorkArea
protected
array<int, int>
$defaultWorkArea
= []
$h
protected
int<0, max>
$h
= 0
$jpegQuality
protected
int<10, 100>
$jpegQuality
= 85
$objBB
protected
array<string|int, mixed>
$objBB
= []
$offset
protected
array<int, int>
$offset
$saveAlphaLayer
Preserve the alpha transparency layer of read PNG images
protected
bool
$saveAlphaLayer
= false
$w
protected
int<0, max>
$w
= 0
$webpQuality
protected
int<10, 101>
$webpQuality
= 85
$workArea
protected
array<int, int>
$workArea
= []
$XY
protected
array{0?: int<0, max>, 1?: int<0, max>}
$XY
= []
Methods
__construct()
public
__construct() : mixed
calcBBox()
Calculates bounding box information for the TEXT GIFBUILDER object.
public
calcBBox(array<string|int, mixed> $conf) : array<string|int, mixed>
Parameters
- $conf : array<string|int, mixed>
-
TypoScript array for the TEXT GIFBUILDER object
Tags
Return values
array<string|int, mixed> —Array with three keys [0]/[1] being x/y and [2] being the bounding box array
calcOffset()
Calculation of offset using "splitCalc" and insertion of dimensions from other GIFBUILDER objects.
public
calcOffset(string $string) : string
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.
Return values
string —The resolved string with each part (separated by comma) returned separated by comma
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 destroys the image and returns the ImageResource DTO.
public
gifBuild() : ImageResource|null
Tags
Return values
ImageResource|null —Returns the ImageResource DTO with file information from ContentObjectRenderer::getImgResource() - or NULL
imageCreateFromFile()
Creates a new GDlib image resource based on the input image filename.
public
imageCreateFromFile(string $sourceImg) : GdImage|false
If it fails creating an image from the input file a blank gray image with the dimensions of the input image will be created instead.
Parameters
- $sourceImg : string
-
Image filename
Return values
GdImage|falseImageWrite()
Writes the input GDlib image pointer to file
public
ImageWrite(GdImage &$destImg, string $theImage[, int $quality = 0 ][, int<-1, 10> $speed = -1 ]) : bool
Parameters
- $destImg : GdImage
-
The GDlib image resource pointer
- $theImage : string
-
The absolute file path to write to
- $quality : int = 0
-
The image quality (for JPEG, WebP and AVIF files)
- $speed : int<-1, 10> = -1
-
The image speed (for AVIFs), 0 (slow, smaller file) to 10 (fast, larger file), -1 for default (=6)
Tags
Return values
bool —The output of either imageGif, imagePng, imageJpeg, imagewebp or imageavif based on the filename to write
makeBox()
Implements the "BOX" GIFBUILDER object
public
makeBox(GdImage &$im, array<string|int, mixed> $conf, array<string|int, mixed> $workArea) : void
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
- $workArea : array<string|int, mixed>
-
The current working area coordinates.
Tags
makeEllipse()
Implements the "Ellipse" GIFBUILDER object Example Typoscript: file = GIFBUILDER file { XY = 200,200 format = jpg quality = 100 10 = ELLIPSE 10.dimensions = 100,100,50,50 10.color = red
public
makeEllipse(GdImage &$im, array<string|int, mixed> $conf, array<string|int, mixed> $workArea) : void
$workArea = X,Y $conf['dimensions'] = offset x, offset y, width of ellipse, height of ellipse
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
- $workArea : array<string|int, mixed>
-
The current working area coordinates.
Tags
makeShadow()
Implements the "SHADOW" GIFBUILDER object / property for the TEXT object The blurred shadow is composited through an in-memory mask.
public
makeShadow(GdImage &$im, array<string|int, mixed> $conf, array<string|int, mixed> $workArea, array<string|int, mixed> $txtConf) : void
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
- $workArea : array<string|int, mixed>
-
The current working area coordinates.
- $txtConf : array<string|int, mixed>
-
TypoScript array with configuration for the associated TEXT GIFBUILDER object.
Tags
makeText()
Implements the "TEXT" GIFBUILDER object
public
makeText(GdImage &$im, array<string|int, mixed> $conf, array<string|int, mixed> $workArea) : void
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
- $workArea : array<string|int, mixed>
-
The current working area coordinates.
Tags
start()
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.
public
start(array<string|int, mixed> $conf, array<string|int, mixed> $data) : void
Modifies the ->setup, ->objBB internal arrays
Parameters
- $conf : array<string|int, mixed>
-
TypoScript properties for the GIFBUILDER session. Stored internally in the variable ->setup
- $data : array<string|int, mixed>
-
The current data record from \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer. Stored internally in the variable ->data
Tags
adjust()
Implements the "ADJUST" GIFBUILDER object
protected
adjust(GdImage &$im, array<string|int, mixed> $conf) : void
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
Tags
applyOffset()
Applies offset value to coordinated in $cords.
protected
applyOffset(array<string|int, mixed> $cords, array<string|int, mixed> $offset) : array<string|int, mixed>
Basically the value of key 0/1 of $OFFSET is added to keys 0/1 of $cords
Parameters
- $cords : array<string|int, mixed>
-
Integer coordinates in key 0/1
- $offset : array<string|int, mixed>
-
Offset values in key 0/1
Return values
array<string|int, mixed> —Modified $cords array
calculateFunctions()
Calculates special functions: + max([10.h], [20.h]) -> gets the maximum of the given values
protected
calculateFunctions(string $string) : string
Parameters
- $string : string
-
The raw string with functions to be calculated
Return values
string —The calculated values
calculateMaximum()
Calculates the maximum of a set of values defined like "[10.h],[20.h],1000"
protected
calculateMaximum(string $value) : int
Parameters
- $value : string
-
The string to be used to calculate the maximum (e.g. "[10.h],[20.h],1000")
Return values
int —The maximum value of the given comma separated and calculated values
calculateValue()
Calculates the value concerning the dimensions of objects.
protected
calculateValue(string $string) : int
Parameters
- $string : string
-
The string to be calculated (e.g. "[20.h]+13")
Tags
Return values
int —The calculated value (e.g. "23")
calcWordSpacing()
Calculates the spacing and wordSpacing values
protected
calcWordSpacing(array<string|int, mixed> $conf[, int $scaleFactor = 1 ]) : array<string|int, mixed>
Parameters
- $conf : array<string|int, mixed>
-
TypoScript array for the TEXT GIFBUILDER object
- $scaleFactor : int = 1
-
TypoScript value from eg $conf['niceText.']['scaleFactor']
Tags
Return values
array<string|int, mixed> —Array with two keys [0]/[1] being array($spacing,$wordSpacing)
checkTextObj()
Initializing/Cleaning of TypoScript properties for TEXT GIFBUILDER objects
protected
checkTextObj(array<string|int, mixed> $conf) : array<string|int, mixed>|null
'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
- $conf : array<string|int, mixed>
-
GIFBUILDER object TypoScript properties
Return values
array<string|int, mixed>|null —Modified $conf array IF the "text" property is not blank
circleOffset()
Creates some offset values in an array used to simulate a circularly applied outline around TEXT
protected
circleOffset(int $distance, int $iterations) : array<string|int, mixed>
Parameters
- $distance : int
-
Distance
- $iterations : int
-
Iterations.
Tags
Return values
array<string|int, mixed>compensateFontSizeiBasedOnFreetypeDpi()
Function to compensate for DPI resolution.
protected
compensateFontSizeiBasedOnFreetypeDpi(float $fontSize) : float
FreeType 2 always has 96 dpi, so it is hard-coded at this place.
Parameters
- $fontSize : float
-
font size for freetype function call
Return values
float —compensated font size based on 96 dpi
convertColor()
Converts a "HTML-color" TypoScript datatype to RGB-values.
protected
convertColor(string $string) : array<string|int, mixed>
Default is 0,0,0
Parameters
- $string : string
-
"HTML-color" data type string, eg. 'red', '#ffeedd' or '255,0,255'. You can also add a modifying operator afterwards. There are two options: "255,0,255 : 20" - will add 20 to values, result is "255,20,255". Or "255,0,255 : *1.23" which will multiply all RGB values with 1.23
Return values
array<string|int, mixed> —RGB values in key 0/1/2 of the array
copyGifOntoGif()
Copies two GDlib image pointers onto each other, using TypoScript configuration from $conf and the input $workArea definition.
protected
copyGifOntoGif(GdImage &$im, GdImage &$cpImg, array<string|int, mixed> $conf, array<string|int, mixed> $workArea) : void
Parameters
- $im : GdImage
-
GDlib image pointer, destination (bottom image)
- $cpImg : GdImage
-
GDlib image pointer, source (top image)
- $conf : array<string|int, mixed>
-
TypoScript array with the properties for the IMAGE GIFBUILDER object. Only used for the "tile" property value.
- $workArea : array<string|int, mixed>
-
Work area
copyImageOntoImage()
Implements the "IMAGE" GIFBUILDER object, when the "mask" property is FALSE (using only $conf['file'])
protected
copyImageOntoImage(GdImage &$im, array<string|int, mixed> $conf, array<string|int, mixed> $workArea) : void
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
- $workArea : array<string|int, mixed>
-
The current working area coordinates.
Tags
crop()
Implements the "CROP" GIFBUILDER object
protected
crop(GdImage &$im, array<string|int, mixed> $conf) : void
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
Tags
extension()
Returns the file extension used in the filename
protected
extension() : string
Return values
stringfileName()
Calculates the GIFBUILDER output filename based on a serialized, hashed value of this->setup and prefixes the original filename.
protected
fileName() : string
The filename gets an additional prefix (max 100 characters), something like "GB_MD5HASH_myfilename_is_very_long_and_such.jpg".
Return values
stringfontResize()
Function that finds the right fontsize that will render the textstring within a certain width
protected
fontResize(array<string|int, mixed> $conf) : int
Parameters
- $conf : array<string|int, mixed>
-
The TypoScript properties of the TEXT GIFBUILDER object
Tags
Return values
int —The new fontSize
getBreakSpace()
Gets the break space for each new line.
protected
getBreakSpace(array<string|int, mixed> $conf[, array<string|int, mixed> $boundingBox = [] ]) : int
Parameters
- $conf : array<string|int, mixed>
-
TypoScript configuration for the currently rendered object
- $boundingBox : array<string|int, mixed> = []
-
The bounding box for the currently rendered object
Return values
int —The break space
getRenderedTextWidth()
Gets the rendered text width
protected
getRenderedTextWidth(string $text, array<string|int, mixed> $conf) : int
Parameters
- $text : string
- $conf : array<string|int, mixed>
Return values
intgetResource()
Returns an "imgResource" creating an instance of the ContentObjectRenderer class and calling ContentObjectRenderer::getImgResource
protected
getResource(string|File $file, array<string|int, mixed> $fileArray) : ImageResource|null
Parameters
- $file : string|File
-
Filename value OR the string "GIFBUILDER", see documentation in TSref for the "datatype" called "imgResource" - can also be a FAL file
- $fileArray : array<string|int, mixed>
-
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)
Tags
Return values
ImageResource|null —Returns the ImageResource DTO with file information from ContentObjectRenderer::getImgResource() - or NULL
getTextScalFactor()
Calculates and returns the niceText.scaleFactor
protected
getTextScalFactor(array<string|int, mixed> $conf) : int
Parameters
- $conf : array<string|int, mixed>
-
TypoScript array for the TEXT GIFBUILDER object
Return values
int —TypoScript value from eg $conf['niceText.']['scaleFactor']
getWordPairsForLineBreak()
Gets the word pairs used for automatic line breaks.
protected
getWordPairsForLineBreak(string $string) : array<string|int, mixed>
Parameters
- $string : string
Return values
array<string|int, mixed>hexColor()
Returns the HEX color value for an RGB color array
protected
hexColor(array<string|int, mixed> $color) : string
Parameters
- $color : array<string|int, mixed>
-
RGB color array
Return values
string —HEX color value
imagecopyresized()
Alternative function for using the similar PHP function imagecopyresized(). Used for GD2 only.
protected
imagecopyresized(GdImage $dstImg, GdImage &$srcImg, int $dstX, int $dstY, int $srcX, int $srcY, int $dstWidth, int $dstHeight, int $srcWidth, int $srcHeight) : GdImage
OK, the reason for this stupid fix is the following story: GD1.x was capable of copying two images together and combining their palettes! GD2 is apparently not. With GD2 only the palette of the dest-image is used which mostly results in totally black images when trying to copy a color-ful image onto the destination. The GD2-fix is to
- Create a blank TRUE-COLOR image
- Copy the destination image onto that one
- Then do the actual operation; Copying the source (top image) onto that
- ... and return the result pointer.
- Reduce colors (if we do not, the result may become strange!) It works, but the resulting images is now a true-color PNG which may be very large. So, why not use 'imagetruecolortopalette ($im, TRUE, 256)' - well because it does NOT WORK! So simple is that.
Parameters
- $dstImg : GdImage
-
Destination image
- $srcImg : GdImage
-
Source image
- $dstX : int
-
Destination x-coordinate
- $dstY : int
-
Destination y-coordinate
- $srcX : int
-
Source x-coordinate
- $srcY : int
-
Source y-coordinate
- $dstWidth : int
-
Destination width
- $dstHeight : int
-
Destination height
- $srcWidth : int
-
Source width
- $srcHeight : int
-
Source height
Return values
GdImageImageTTFBBoxWrapper()
Wrapper for ImageTTFBBox
protected
ImageTTFBBoxWrapper(int $fontSize, int $angle, string $fontFile, string $string, array<string|int, mixed> $splitRendering[, int $sF = 1 ]) : array<string|int, mixed>
Parameters
- $fontSize : int
-
(See argument for PHP function ImageTTFBBox())
- $angle : int
-
(See argument for PHP function ImageTTFBBox())
- $fontFile : string
-
(See argument for PHP function ImageTTFBBox())
- $string : string
-
(See argument for PHP function ImageTTFBBox())
- $splitRendering : array<string|int, mixed>
-
Split-rendering configuration
- $sF : int = 1
-
Scale factor
Return values
array<string|int, mixed> —Information array.
ImageTTFTextWrapper()
Wrapper for ImageTTFText
protected
ImageTTFTextWrapper(GdImage &$im, int $fontSize, int $angle, int $x, int $y, int $color, string $fontFile, string $string, array<string|int, mixed> $splitRendering[, int $sF = 1 ]) : void
Parameters
- $im : GdImage
-
(See argument for PHP function imageTTFtext())
- $fontSize : int
-
(See argument for PHP function imageTTFtext())
- $angle : int
-
(See argument for PHP function imageTTFtext())
- $x : int
-
(See argument for PHP function imageTTFtext())
- $y : int
-
(See argument for PHP function imageTTFtext())
- $color : int
-
(See argument for PHP function imageTTFtext())
- $fontFile : string
-
(See argument for PHP function imageTTFtext())
- $string : string
-
(See argument for PHP function imageTTFtext()). UTF-8 string, possibly with entities in.
- $splitRendering : array<string|int, mixed>
-
Split-rendering configuration
- $sF : int = 1
-
Scale factor
make()
The actual rendering of the image file.
protected
make() : GdImage
Creates a GDlib resource, works on that and returns it.
Basically sets the dimensions, the background color, the traverses the array of GIFBUILDER objects and finally setting the transparent color if defined.
Called by gifBuild()
Tags
Return values
GdImagemakeEffect()
Implements the "EFFECT" GIFBUILDER object.
protected
makeEffect(GdImage &$im, array<string|int, mixed> $conf) : void
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
Tags
makeEmboss()
Implements the "EMBOSS" GIFBUILDER object / property for the TEXT object
protected
makeEmboss(GdImage &$im, array<string|int, mixed> $conf, array<string|int, mixed> $workArea, array<string|int, mixed> $txtConf) : void
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
- $workArea : array<string|int, mixed>
-
The current working area coordinates.
- $txtConf : array<string|int, mixed>
-
TypoScript array with configuration for the associated TEXT GIFBUILDER object.
Tags
makeOutline()
Implements the "OUTLINE" GIFBUILDER object / property for the TEXT object
protected
makeOutline(GdImage &$im, array<string|int, mixed> $conf, array<string|int, mixed> $workArea, array<string|int, mixed> $txtConf) : void
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
- $workArea : array<string|int, mixed>
-
The current working area coordinates.
- $txtConf : array<string|int, mixed>
-
TypoScript array with configuration for the associated TEXT GIFBUILDER object.
Tags
maskImageOntoImage()
Implements the "IMAGE" GIFBUILDER object, when the "mask" property is TRUE.
protected
maskImageOntoImage(GdImage &$im, array<string|int, mixed> $conf, array<string|int, mixed> $workArea) : void
It reads the two images defined by $conf['file'] and $conf['mask'] and copies the $conf['file'] onto the input image pointer image using the $conf['mask'] as a grayscale mask
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
- $workArea : array<string|int, mixed>
-
The current working area coordinates.
Tags
objPosition()
Create an array with object position/boundaries based on input TypoScript configuration (such as the "align" property is used), the work area definition and $BB array
protected
objPosition(array<string|int, mixed> $conf, array<string|int, mixed> $workArea, array<string|int, mixed> $BB) : array<string|int, mixed>
Parameters
- $conf : array<string|int, mixed>
-
TypoScript configuration for a GIFBUILDER object
- $workArea : array<string|int, mixed>
-
Workarea definition
- $BB : array<string|int, mixed>
-
BB (Bounding box) array. Not just used for TEXT objects but also for others
Tags
Return values
array<string|int, mixed> —[0]=x, [1]=y, [2]=w, [3]=h
output()
Writing the image pointer, to file based on the extension of the input filename.
protected
output(GdImage $gdImage, string $file) : void
Uses $this->setup['quality'] for jpg images to reduce size/quality if needed.
Parameters
- $gdImage : GdImage
-
The GDlib image resource pointer
- $file : string
-
The absolute filename to write to
Tags
renderTTFText()
Renders a regular text and takes care of a possible line break automatically.
protected
renderTTFText(GdImage &$im, int $fontSize, int $angle, int $x, int $y, int $color, string $fontFile, string $string, array<string|int, mixed> $splitRendering, array<string|int, mixed> $conf[, int $sF = 1 ]) : void
Parameters
- $im : GdImage
-
(See argument for PHP function imageTTFtext())
- $fontSize : int
-
(See argument for PHP function imageTTFtext())
- $angle : int
-
(See argument for PHP function imageTTFtext())
- $x : int
-
(See argument for PHP function imageTTFtext())
- $y : int
-
(See argument for PHP function imageTTFtext())
- $color : int
-
(See argument for PHP function imageTTFtext())
- $fontFile : string
-
(See argument for PHP function imageTTFtext())
- $string : string
-
(See argument for PHP function imageTTFtext()). UTF-8 string, possibly with entities in.
- $splitRendering : array<string|int, mixed>
-
Split-rendering configuration
- $conf : array<string|int, mixed>
-
The configuration
- $sF : int = 1
-
Scale factor
scale()
Implements the "SCALE" GIFBUILDER object
protected
scale(GdImage &$im, array<string|int, mixed> $conf) : void
Parameters
- $im : GdImage
-
GDlib image pointer
- $conf : array<string|int, mixed>
-
TypoScript array with configuration for the GIFBUILDER object.
Tags
setWorkArea()
Implements the "WORKAREA" GIFBUILDER object when setting it Setting internal working area boundaries (->workArea)
protected
setWorkArea(string $workArea) : void
Parameters
- $workArea : string
-
Working area dimensions, comma separated
Tags
SpacedImageTTFText()
Printing text onto an image like the PHP function imageTTFText does but in addition it offers options for spacing of letters and words.
protected
SpacedImageTTFText(GdImage &$im, int $fontSize, int $angle, int $x, int $y, int $Fcolor, string $fontFile, string $text, int $spacing, int $wordSpacing, array<string|int, mixed> $splitRenderingConf[, int $sF = 1 ]) : void
Spacing is done by printing one char at a time and this means that the spacing is rather uneven and probably not very nice. See
Parameters
- $im : GdImage
-
(See argument for PHP function imageTTFtext())
- $fontSize : int
-
(See argument for PHP function imageTTFtext())
- $angle : int
-
(See argument for PHP function imageTTFtext())
- $x : int
-
(See argument for PHP function imageTTFtext())
- $y : int
-
(See argument for PHP function imageTTFtext())
- $Fcolor : int
-
(See argument for PHP function imageTTFtext())
- $fontFile : string
-
(See argument for PHP function imageTTFtext())
- $text : string
-
(See argument for PHP function imageTTFtext()). UTF-8 string, possibly with entities in.
- $spacing : int
-
The spacing of letters in pixels
- $wordSpacing : int
-
The spacing of words in pixels
- $splitRenderingConf : array<string|int, mixed>
-
Array
- $sF : int = 1
-
Scale factor
splitString()
Splitting a string for ImageTTFBBox up into an array where each part has its own configuration options.
protected
splitString(string $string, array<string|int, mixed> $splitRendering, int $fontSize, string $fontFile) : array<string|int, mixed>
Parameters
- $string : string
-
UTF-8 string
- $splitRendering : array<string|int, mixed>
-
Split-rendering configuration from GIFBUILDER TEXT object.
- $fontSize : int
-
Current fontsize
- $fontFile : string
-
Current font file
Return values
array<string|int, mixed> —Array with input string splitted according to configuration
txtPosition()
Calculates text position for printing the text onto the image based on configuration like alignment and workarea.
protected
txtPosition(array<string|int, mixed> $conf, array<string|int, mixed> $workArea, array<string|int, mixed> $BB) : array<string|int, mixed>
Parameters
- $conf : array<string|int, mixed>
-
TypoScript array for the TEXT GIFBUILDER object
- $workArea : array<string|int, mixed>
-
Work area definition
- $BB : array<string|int, mixed>
-
Bounding box information, was set in start()
Tags
Return values
array<string|int, mixed> —[0]=x, [1]=y, [2]=w, [3]=h
unifyColors()
Unifies all colors given in the colArr color array to the first color in the array.
protected
unifyColors(GdImage &$img, array<string|int, mixed> $colArr, bool $closest) : int
Parameters
- $img : GdImage
-
Image resource
- $colArr : array<string|int, mixed>
-
Array containing RGB color arrays
- $closest : bool
Return values
int —The index of the unified color