GifBuilder

class \TYPO3\CMS\Frontend\Imaging\GifBuilder

Implements
LoggerAwareInterface
Uses
LoggerAwareTrait

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

Interfaces

LoggerAwareInterface

Properties

$setup  : array
This holds the operational setup.
$avifQuality  : int<-1, 100>
$charRangeMap  : array<string, array>
$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
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
$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
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
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
Calculates the spacing and wordSpacing values
checkTextObj()  : array|null
Initializing/Cleaning of TypoScript properties for TEXT GIFBUILDER objects
circleOffset()  : array
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
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
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
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
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
Splitting a string for ImageTTFBBox up into an array where each part has its own configuration options.
txtPosition()  : array
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 $setup = []

Basically this is a TypoScript array with properties.

$avifQuality

protected int<-1, 100> $avifQuality = 85

$charRangeMap

protected array<string, array> $charRangeMap = []

$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…
Show the full value['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 = []

$data

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

protected array $data = []

$defaultWorkArea

protected array<int, int> $defaultWorkArea = []

$jpegQuality

protected int<10, 100> $jpegQuality = 85

$saveAlphaLayer

Preserve the alpha transparency layer of read PNG images

protected bool $saveAlphaLayer = false

$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

calcBBox()

Calculates bounding box information for the TEXT GIFBUILDER object.

public calcBBox(array $conf) : array

Parameters

$conf : array

TypoScript array for the TEXT GIFBUILDER object

Tags

see
txtPosition()
see
start()

Return values

array —

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

see
make()
see
fileName()

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|false

ImageWrite()

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

see
maskImageOntoImage()
see
scale()
see
output()

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 $conf, array $workArea) : void

Parameters

$im : GdImage

GDlib image pointer

$conf : array

TypoScript array with configuration for the GIFBUILDER object.

$workArea : array

The current working area coordinates.

Tags

see
make()

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 $conf, array $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

TypoScript array with configuration for the GIFBUILDER object.

$workArea : array

The current working area coordinates.

Tags

see
make()

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 $conf, array $workArea, array $txtConf) : void

Parameters

$im : GdImage

GDlib image pointer

$conf : array

TypoScript array with configuration for the GIFBUILDER object.

$workArea : array

The current working area coordinates.

$txtConf : array

TypoScript array with configuration for the associated TEXT GIFBUILDER object.

Tags

see
make()
see
makeText()
see
makeEmboss()

makeText()

Implements the "TEXT" GIFBUILDER object

public makeText(GdImage &$im, array $conf, array $workArea) : void

Parameters

$im : GdImage

GDlib image pointer

$conf : array

TypoScript array with configuration for the GIFBUILDER object.

$workArea : array

The current working area coordinates.

Tags

see
make()

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 $conf, array $data) : void

Modifies the ->setup, ->objBB internal arrays

Parameters

$conf : array

TypoScript properties for the GIFBUILDER session. Stored internally in the variable ->setup

$data : array

The current data record from \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer. Stored internally in the variable ->data

Tags

see
ContentObjectRenderer::getImgResource()

adjust()

Implements the "ADJUST" GIFBUILDER object

protected adjust(GdImage &$im, array $conf) : void

Parameters

$im : GdImage

GDlib image pointer

$conf : array

TypoScript array with configuration for the GIFBUILDER object.

Tags

see
make()
see
autoLevels()
see
outputLevels()
see
inputLevels()

applyOffset()

Applies offset value to coordinated in $cords.

protected applyOffset(array $cords, array $offset) : array

Basically the value of key 0/1 of $OFFSET is added to keys 0/1 of $cords

Parameters

$cords : array

Integer coordinates in key 0/1

$offset : array

Offset values in key 0/1

Return values

array —

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

see
calcOffset()

Return values

int —

The calculated value (e.g. "23")

calcWordSpacing()

Calculates the spacing and wordSpacing values

protected calcWordSpacing(array $conf[, int $scaleFactor = 1 ]) : array

Parameters

$conf : array

TypoScript array for the TEXT GIFBUILDER object

$scaleFactor : int = 1

TypoScript value from eg $conf['niceText.']['scaleFactor']

Tags

see
calcBBox()

Return values

array —

Array with two keys [0]/[1] being array($spacing,$wordSpacing)

checkTextObj()

Initializing/Cleaning of TypoScript properties for TEXT GIFBUILDER objects

protected checkTextObj(array $conf) : array|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

GIFBUILDER object TypoScript properties

Return values

array|null —

Modified $conf array IF the "text" property is not blank and GD can render text

circleOffset()

Creates some offset values in an array used to simulate a circularly applied outline around TEXT

protected circleOffset(int $distance, int $iterations) : array

Parameters

$distance : int

Distance

$iterations : int

Iterations.

Tags

see
makeOutline()

Return values

array

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

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 —

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 $conf, array $workArea) : void

Parameters

$im : GdImage

GDlib image pointer, destination (bottom image)

$cpImg : GdImage

GDlib image pointer, source (top image)

$conf : array

TypoScript array with the properties for the IMAGE GIFBUILDER object. Only used for the "tile" property value.

$workArea : array

Work area

copyImageOntoImage()

Implements the "IMAGE" GIFBUILDER object, when the "mask" property is FALSE (using only $conf['file'])

protected copyImageOntoImage(GdImage &$im, array $conf, array $workArea) : void

Parameters

$im : GdImage

GDlib image pointer

$conf : array

TypoScript array with configuration for the GIFBUILDER object.

$workArea : array

The current working area coordinates.

Tags

see
make()
see
maskImageOntoImage()

crop()

Implements the "CROP" GIFBUILDER object

protected crop(GdImage &$im, array $conf) : void

Parameters

$im : GdImage

GDlib image pointer

$conf : array

TypoScript array with configuration for the GIFBUILDER object.

Tags

see
make()

extension()

Returns the file extension used in the filename

protected extension() : string

Return values

string

fileName()

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

string

fontResize()

Function that finds the right fontsize that will render the textstring within a certain width

protected fontResize(array $conf) : int

Parameters

$conf : array

The TypoScript properties of the TEXT GIFBUILDER object

Tags

see
start()

Return values

int —

The new fontSize

getBreakSpace()

Gets the break space for each new line.

protected getBreakSpace(array $conf[, array $boundingBox = [] ]) : int

Parameters

$conf : array

TypoScript configuration for the currently rendered object

$boundingBox : array = []

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 $conf) : int

Parameters

$text : string
$conf : array

Return values

int

getResource()

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

protected getResource(string|File $file, array $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

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

see
ContentObjectRenderer::getImgResource()

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 $conf) : int

Parameters

$conf : array

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

Parameters

$string : string

Return values

array

hexColor()

Returns the HEX color value for an RGB color array

protected hexColor(array $color) : string

Parameters

$color : array

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

  1. Create a blank TRUE-COLOR image
  2. Copy the destination image onto that one
  3. Then do the actual operation; Copying the source (top image) onto that
  4. ... and return the result pointer.
  5. 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

GdImage

ImageTTFBBoxWrapper()

Wrapper for ImageTTFBBox

protected ImageTTFBBoxWrapper(int $fontSize, int $angle, string $fontFile, string $string, array $splitRendering[, int $sF = 1 ]) : array

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

Split-rendering configuration

$sF : int = 1

Scale factor

Return values

array —

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 $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

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

see
gifBuild()

Return values

GdImage

makeEffect()

Implements the "EFFECT" GIFBUILDER object.

protected makeEffect(GdImage &$im, array $conf) : void

Parameters

$im : GdImage

GDlib image pointer

$conf : array

TypoScript array with configuration for the GIFBUILDER object.

Tags

see
make()

makeEmboss()

Implements the "EMBOSS" GIFBUILDER object / property for the TEXT object

protected makeEmboss(GdImage &$im, array $conf, array $workArea, array $txtConf) : void

Parameters

$im : GdImage

GDlib image pointer

$conf : array

TypoScript array with configuration for the GIFBUILDER object.

$workArea : array

The current working area coordinates.

$txtConf : array

TypoScript array with configuration for the associated TEXT GIFBUILDER object.

Tags

see
make()
see
makeShadow()

makeOutline()

Implements the "OUTLINE" GIFBUILDER object / property for the TEXT object

protected makeOutline(GdImage &$im, array $conf, array $workArea, array $txtConf) : void

Parameters

$im : GdImage

GDlib image pointer

$conf : array

TypoScript array with configuration for the GIFBUILDER object.

$workArea : array

The current working area coordinates.

$txtConf : array

TypoScript array with configuration for the associated TEXT GIFBUILDER object.

Tags

see
make()
see
makeText()

maskImageOntoImage()

Implements the "IMAGE" GIFBUILDER object, when the "mask" property is TRUE.

protected maskImageOntoImage(GdImage &$im, array $conf, array $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

TypoScript array with configuration for the GIFBUILDER object.

$workArea : array

The current working area coordinates.

Tags

see
make()

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 $conf, array $workArea, array $BB) : array

Parameters

$conf : array

TypoScript configuration for a GIFBUILDER object

$workArea : array

Workarea definition

$BB : array

BB (Bounding box) array. Not just used for TEXT objects but also for others

Tags

see
copyGifOntoGif()
see
makeBox()
see
crop()

Return values

array —

[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

see
gifBuild()

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 $splitRendering, array $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

Split-rendering configuration

$conf : array

The configuration

$sF : int = 1

Scale factor

scale()

Implements the "SCALE" GIFBUILDER object

protected scale(GdImage &$im, array $conf) : void

Parameters

$im : GdImage

GDlib image pointer

$conf : array

TypoScript array with configuration for the GIFBUILDER object.

Tags

see
make()

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

see
make()

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 $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

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 $splitRendering, int $fontSize, string $fontFile) : array

Parameters

$string : string

UTF-8 string

$splitRendering : array

Split-rendering configuration from GIFBUILDER TEXT object.

$fontSize : int

Current fontsize

$fontFile : string

Current font file

Return values

array —

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 $conf, array $workArea, array $BB) : array

Parameters

$conf : array

TypoScript array for the TEXT GIFBUILDER object

$workArea : array

Work area definition

$BB : array

Bounding box information, was set in start()

Tags

see
makeText()

Return values

array —

[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 $colArr, bool $closest) : int

Parameters

$img : GdImage

Image resource

$colArr : array

Array containing RGB color arrays

$closest : bool

Return values

int —

The index of the unified color

On this page