Documentation

QRImagick extends QROutputAbstract
in package

ImageMagick output module (requires ext-imagick)

Tags
see
https://php.net/manual/book.imagick.php
see
https://phpimagick.com

Table of Contents

Properties

$backgroundColor  : ImagickPixel
The allocated background color
$circleDiameter  : float
$circleRadius  : float
$connectPaths  : bool
$drawCircularModules  : bool
$drawLightModules  : bool
$eol  : string
$excludeFromConnect  : array<string|int, int>
$imagick  : Imagick
The main image instance
$imagickDraw  : ImagickDraw
The main draw instance
$keepAsSquare  : array<string|int, int>
$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
the options instance
$scale  : int

Methods

__construct()  : mixed
QROutputAbstract constructor.
dump()  : string|Imagick
Generates the output, optionally dumps it to a file, and returns it
moduleValueIsValid()  : bool
note: we're not necessarily validating the several values, just checking the general syntax
collectModules()  : array<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()  : Imagick
Creates a new Imagick instance
drawImage()  : void
Creates the QR image via ImagickDraw
getDefaultModuleValue()  : ImagickPixel
Returns a default value for either dark or light modules (return value depends on the output class)
getModuleValue()  : mixed
Returns the prepared value for the given $M_TYPE
getModuleValueAt()  : mixed
Returns the prepared module value at the given coordinate [$x, $y] (convenience)
getOutputDimensions()  : array<string|int, int>
Returns a 2 element array with the current output width and height
guessMimeType()  : string
Guesses the mime type from the given $imageData
module()  : void
draws a single pixel at the given position
prepareModuleValue()  : ImagickPixel
Prepares the value for the given input (return value depends on the output class)
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

$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, int> $excludeFromConnect
Tags
see
QROptions::$excludeFromConnect

$imagick

The main image instance

protected Imagick $imagick

$imagickDraw

The main draw instance

protected ImagickDraw $imagickDraw

$keepAsSquare

protected array<string|int, int> $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
Tags
phpstan-var

array<int, mixed>

Methods

dump()

Generates the output, optionally dumps it to a file, and returns it

public dump([string|null $file = null ]) : string|Imagick

please note that the value of QROptions::$cachefile is already evaluated at this point. if the output module is invoked manually, it has no effect at all. you need to supply the $file parameter here in that case (or handle the option value in your custom output module).

Parameters
$file : string|null = null
Return values
string|Imagick

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<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<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 Imagick instance

protected createImage() : Imagick
Return values
Imagick

drawImage()

Creates the QR image via ImagickDraw

protected drawImage() : void

getDefaultModuleValue()

Returns a default value for either dark or light modules (return value depends on the output class)

protected getDefaultModuleValue(bool $isDark) : ImagickPixel
Parameters
$isDark : bool
Return values
ImagickPixel

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

getModuleValueAt()

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

protected getModuleValueAt(int $x, int $y) : mixed
Parameters
$x : int
$y : int

getOutputDimensions()

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

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

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, int>

guessMimeType()

Guesses the mime type from the given $imageData

protected guessMimeType(string $imageData) : string
Parameters
$imageData : string
Tags
throws
QRCodeOutputException
Return values
string

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 (return value depends on the output class)

protected prepareModuleValue(mixed $value) : ImagickPixel
Parameters
$value : mixed
Return values
ImagickPixel

saveToFile()

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

protected saveToFile(string $data[, string|null $file = null ]) : void
Parameters
$data : string
$file : string|null = 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|null $mime = null ]) : string

The mime type can be set via class constant MIME_TYPE in child classes, or given via $mime, otherwise it is guessed from the image $data.

Parameters
$data : string
$mime : string|null = null
Return values
string

        
On this page

Search results