QRImage
extends QRGdImage
in package
Converts the matrix into GD images, raw or base64 output (requires ext-gd)
Tags
Table of Contents
- $image : resource|GdImage
- The GD image resource
- $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
- $scale : int
- the current scaling for a QR pixel
- __construct() : mixed
- QROutputAbstract constructor.
- dump() : string|resource|GdImage
- 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
- dumpImage() : string
- Creates the final image by calling the desired GD output function
- getDefaultModuleValue() : mixed
- Returns a default value for either dark or light modules (return value depends on the output module)
- getModuleValue() : mixed
- Returns the final value for the given input (return value depends on the output module)
- moduleValueIsValid() : bool
- Determines whether the given value is valid
- saveToFile() : void
- saves the qr data to a file
- setMatrixDimensions() : void
- Sets/updates the matrix dimensions
- setModuleValues() : void
- Sets the initial module values
- setPixel() : void
- Creates a single QR pixel with the given settings
- toBase64DataURI() : string
- Returns a base64 data URI for the given string and mime type
Properties
$image
The GD image resource
protected
resource|GdImage
$image
Tags
$length
the side length of the QR image (modules * scale)
protected
int
$length
$matrix
the (filled) data matrix object
protected
QRMatrix
$matrix
$moduleCount
the current size of the QR matrix
protected
int
$moduleCount
Tags
$moduleValues
an (optional) array of color values for the several QR matrix parts
protected
array<string|int, mixed>
$moduleValues
$options
protected
SettingsContainerInterface
$options
$scale
the current scaling for a QR pixel
protected
int
$scale
Tags
Methods
__construct()
QROutputAbstract constructor.
public
__construct(SettingsContainerInterface $options, QRMatrix $matrix) : mixed
Parameters
- $options : SettingsContainerInterface
- $matrix : QRMatrix
Return values
mixed —dump()
public
dump([string $file = null ]) : string|resource|GdImage
Parameters
- $file : string = null
Tags
Return values
string|resource|GdImage —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> —dumpImage()
Creates the final image by calling the desired GD output function
protected
dumpImage() : string
Tags
Return values
string —getDefaultModuleValue()
Returns a default value for either dark or light modules (return value depends on the output module)
protected
abstract getDefaultModuleValue(bool $isDark) : mixed
Parameters
- $isDark : bool
Return values
mixed —getModuleValue()
Returns the final value for the given input (return value depends on the output module)
protected
abstract getModuleValue(mixed $value) : mixed
Parameters
- $value : mixed
Return values
mixed —moduleValueIsValid()
Determines whether the given value is valid
protected
abstract moduleValueIsValid(mixed|null $value) : bool
Parameters
- $value : mixed|null
Return values
bool —saveToFile()
saves the qr data to a file
protected
saveToFile(string $data, string $file) : void
Parameters
- $data : string
- $file : string
Tags
Return values
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
Return values
void —setModuleValues()
Sets the initial module values
protected
setModuleValues() : void
Return values
void —setPixel()
Creates a single QR pixel with the given settings
protected
setPixel(int $x, int $y, int $M_TYPE) : void
Parameters
- $x : int
- $y : int
- $M_TYPE : int
Return values
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