Documentation

QRGdImage extends QROutputAbstract
in package

Converts the matrix into GD images, raw or base64 output (requires ext-gd)

Tags
see
https://php.net/manual/book.image.php

Table of Contents

Properties

$background  : int
The allocated background color
$circleRadius  : float
$connectPaths  : bool
$drawCircularModules  : bool
$drawLightModules  : bool
$eol  : string
$excludeFromConnect  : array<string|int, mixed>
$image  : resource|GdImage
The GD image resource
$keepAsSquare  : array<string|int, mixed>
$length  : int
the side length of the QR image (modules * scale)
$matrix  : QRMatrix
the (filled) data matrix object
$moduleCount  : int
the current size of the QR matrix
$moduleValues  : array<string|int, mixed>
an (optional) array of color values for the several QR matrix parts
$options  : SettingsContainerInterface|QROptions
$scale  : int
$upscaled  : bool
Whether we're running in upscale mode (scale < 20)

Methods

__construct()  : mixed
QROutputAbstract constructor.
dump()  : string|resource|GdImage
moduleValueIsValid()  : bool
checkGD()  : void
Checks whether GD is installed and if the given mode is supported
collectModules()  : array<string|int, mixed>
collects the modules per QRMatrix::M_* type and runs a $transform function on each module and returns an array with the transformed modules
copyVars()  : void
Creates copies of several QROptions values to avoid calling the magic getters in long loops for a significant performance increase.
createImage()  : GdImage|resource
Creates a new GdImage resource and scales it if necessary
drawImage()  : void
Draws the QR image
dumpImage()  : string
Creates the final image by calling the desired GD output function
getDefaultModuleValue()  : mixed|null
Returns a default value for either dark or light modules
getModuleValue()  : mixed
Returns the prepared value for the given $M_TYPE
getModuleValueAt()  : mixed|null
Returns the prepared module value at the given coordinate [$x, $y] (convenience)
getOutputDimensions()  : array<string|int, mixed>
Returns a 2 element array with the current output width and height
module()  : void
Creates a single QR pixel with the given settings
prepareModuleValue()  : mixed|null
Prepares the value for the given input ()
saveToFile()  : void
Saves the qr $data to a $file. If $file is null, nothing happens.
setBgColor()  : void
Sets the background color
setMatrixDimensions()  : void
Sets/updates the matrix dimensions
setModuleValues()  : void
Sets the initial module values
setTransparencyColor()  : void
Sets the transparency color
toBase64DataURI()  : string
Returns a base64 data URI for the given string and mime type

Properties

$background

The allocated background color

protected int $background
Tags
see
imagecolorallocate()

$circleRadius

protected float $circleRadius
Tags
see
QROptions::$circleRadius

$connectPaths

protected bool $connectPaths
Tags
see
QROptions::$connectPaths

$drawCircularModules

protected bool $drawCircularModules
Tags
see
QROptions::$drawCircularModules

$drawLightModules

protected bool $drawLightModules
Tags
see
QROptions::$drawLightModules

$excludeFromConnect

protected array<string|int, mixed> $excludeFromConnect
Tags
see
QROptions::$excludeFromConnect

$image

The GD image resource

protected resource|GdImage $image
Tags
see
imagecreatetruecolor()

$keepAsSquare

protected array<string|int, mixed> $keepAsSquare
Tags
see
QROptions::$keepAsSquare

$length

the side length of the QR image (modules * scale)

protected int $length

$moduleValues

an (optional) array of color values for the several QR matrix parts

protected array<string|int, mixed> $moduleValues

$upscaled

Whether we're running in upscale mode (scale < 20)

protected bool $upscaled = false
Tags
see
QROptions::$drawCircularModules

Methods

__construct()

QROutputAbstract constructor.

public __construct(SettingsContainerInterface $options, QRMatrix $matrix) : mixed
Parameters
$options : SettingsContainerInterface
$matrix : QRMatrix
Tags
inheritDoc
throws
QRCodeOutputException
noinspection

PhpMissingParentConstructorInspection

dump()

public dump([string $file = null ]) : string|resource|GdImage
Parameters
$file : string = null
Tags
inheritDoc
phan-suppress

PhanUndeclaredTypeReturnType, PhanTypeMismatchReturn

throws
ErrorException
Return values
string|resource|GdImage

moduleValueIsValid()

public static moduleValueIsValid(mixed $value) : bool
Parameters
$value : mixed
Tags
inheritDoc
Return values
bool

checkGD()

Checks whether GD is installed and if the given mode is supported

protected checkGD() : void
Tags
throws
QRCodeOutputException
codeCoverageIgnore

collectModules()

collects the modules per QRMatrix::M_* type and runs a $transform function on each module and returns an array with the transformed modules

protected collectModules(Closure $transform) : array<string|int, mixed>

The transform callback is called with the following parameters:

$x - current column $y - current row $M_TYPE - field value $M_TYPE_LAYER - (possibly modified) field value that acts as layer id

Parameters
$transform : Closure
Return values
array<string|int, mixed>

copyVars()

Creates copies of several QROptions values to avoid calling the magic getters in long loops for a significant performance increase.

protected copyVars() : void

These variables are usually used in the "module" methods and are called up to 31329 times (at version 40).

createImage()

Creates a new GdImage resource and scales it if necessary

protected createImage() : GdImage|resource

we're scaling the image up in order to draw crisp round circles, otherwise they appear square-y on small scales

Tags
see
https://github.com/chillerlan/php-qrcode/issues/23
Return values
GdImage|resource

drawImage()

Draws the QR image

protected drawImage() : void

dumpImage()

Creates the final image by calling the desired GD output function

protected dumpImage() : string
Tags
throws
QRCodeOutputException
Return values
string

getDefaultModuleValue()

Returns a default value for either dark or light modules

protected getDefaultModuleValue(bool $isDark) : mixed|null
Parameters
$isDark : bool
Tags
inheritDoc
Return values
mixed|null

return value depends on the output class

getModuleValue()

Returns the prepared value for the given $M_TYPE

protected getModuleValue(int $M_TYPE) : mixed
Parameters
$M_TYPE : int
Tags
throws
QRCodeOutputException

if $moduleValues[$M_TYPE] doesn't exist

Return values
mixed

return value depends on the output class

getModuleValueAt()

Returns the prepared module value at the given coordinate [$x, $y] (convenience)

protected getModuleValueAt(int $x, int $y) : mixed|null
Parameters
$x : int
$y : int
Return values
mixed|null

getOutputDimensions()

Returns a 2 element array with the current output width and height

protected getOutputDimensions() : array<string|int, mixed>

The type and units of the values depend on the output class. The default value is the current module count * scale.

Return values
array<string|int, mixed>

module()

Creates a single QR pixel with the given settings

protected module(int $x, int $y, int $M_TYPE) : void
Parameters
$x : int
$y : int
$M_TYPE : int

prepareModuleValue()

Prepares the value for the given input ()

protected prepareModuleValue(array<string|int, mixed> $value) : mixed|null
Parameters
$value : array<string|int, mixed>
Tags
inheritDoc
throws
QRCodeOutputException
Return values
mixed|null

return value depends on the output class

saveToFile()

Saves the qr $data to a $file. If $file is null, nothing happens.

protected saveToFile(string $data[, string $file = null ]) : void
Parameters
$data : string
$file : string = null
Tags
see
file_put_contents()
see
QROptions::$cachefile
throws
QRCodeOutputException

setBgColor()

Sets the background color

protected setBgColor() : void

setMatrixDimensions()

Sets/updates the matrix dimensions

protected setMatrixDimensions() : void

Call this method if you modify the matrix from within your custom module in case the dimensions have been changed

setModuleValues()

Sets the initial module values

protected setModuleValues() : void

setTransparencyColor()

Sets the transparency color

protected setTransparencyColor() : void

toBase64DataURI()

Returns a base64 data URI for the given string and mime type

protected toBase64DataURI(string $data, string $mime) : string
Parameters
$data : string
$mime : string
Return values
string

        
On this page

Search results