QRImagick
extends QROutputAbstract
in package
ImageMagick output module (requires ext-imagick)
Tags
Table of Contents
Properties
- $backgroundColor : ImagickPixel
- The allocated background color
- $imagick : Imagick
- The main image instance
- $imagickDraw : ImagickDraw
- The main draw instance
- $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
- the current scaling for a QR pixel
Methods
- __construct() : mixed
- QROutputAbstract constructor.
- dump() : string|Imagick
- moduleValueIsValid() : bool
- note: we're not necessarily validating the several values, just checking the general syntax
- 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
- createImage() : Imagick
- Creates a new Imagick instance
- drawImage() : void
- Creates the QR image via ImagickDraw
- getDefaultModuleValue() : mixed|null
- Returns a default value for either dark or light modules
- getModuleValue() : mixed|null
- 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
- draws a single pixel at the given position
- 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
$backgroundColor
The allocated background color
protected
ImagickPixel
$backgroundColor
$imagick
The main image instance
protected
Imagick
$imagick
$imagickDraw
The main draw instance
protected
ImagickDraw
$imagickDraw
$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|QROptions
$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
Tags
dump()
public
dump([string $file = null ]) : string|Imagick
Parameters
- $file : string = null
Tags
Return values
string|ImagickmoduleValueIsValid()
note: we're not necessarily validating the several values, just checking the general syntax
public
static moduleValueIsValid(mixed $value) : bool
Parameters
- $value : mixed
Tags
Return values
boolcollectModules()
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>createImage()
Creates a new Imagick instance
protected
createImage() : Imagick
Return values
ImagickdrawImage()
Creates the QR image via ImagickDraw
protected
drawImage() : void
getDefaultModuleValue()
Returns a default value for either dark or light modules
protected
getDefaultModuleValue(bool $isDark) : mixed|null
Parameters
- $isDark : bool
Tags
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|null
Parameters
- $M_TYPE : int
Tags
Return values
mixed|null —return value depends on the output class, null if $moduleValues[$M_TYPE] doesn't exist
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|nullgetOutputDimensions()
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()
draws a single pixel at the given position
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(mixed $value) : mixed|null
Parameters
- $value : mixed
Tags
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
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