Menu

## QROptionsTrait

QROptionsTrait.php : 22

The QRCode plug-in settings & setter functionality

### Table of Contents

$addLogoSpace : bool
  Toggles logo space creation
$addQuietzone : bool
  Add a "quiet zone" (margin) according to the QR code spec
$bgColor : mixed|null
  Sets the image background color (if applicable)
$cachefile : string|null
  /path/to/cache.file
$circleRadius : float
  specifies the radius of the modules when $svgDrawCircularModules is set to true
$connectPaths : bool
  whether to connect the paths for the several module types to avoid weird glitches when using gradients etc.
$cssClass : string
  a common css class
$drawCircularModules : bool
  specify whether to draw the modules as filled circles
$drawLightModules : bool
  whether to draw the light (false) modules
$eccLevel : int
  Error correct level
$eol : string
  newline string [HTML, SVG, TEXT]
$excludeFromConnect : array<string|int, mixed>
  specify which paths/patterns to exclude from connecting if $svgConnectPaths is set to true
$fpdfMeasureUnit : string
  Measurement unit for FPDF output: pt, mm, cm, in (defaults to "pt")
$imageBase64 : bool
  toggle base64 or raw image data
$imageTransparencyBG : array<string|int, mixed>
  Sets the background color in GD mode: [R, G, B].
$imageTransparent : bool
  toggle background transparency
$imagickBG : string|null
  Imagick background color
$imagickFormat : string
  Imagick output format
$jpegQuality : int
$keepAsSquare : array<string|int, mixed>
  specifies which module types to exclude when $svgDrawCircularModules is set to true
$logoSpaceHeight : int|null
  height of the logo space
$logoSpaceStartX : int|null
  optional horizontal start position of the logo space (top left corner)
$logoSpaceStartY : int|null
  optional vertical start position of the logo space (top left corner)
$logoSpaceWidth : int|null
  width of the logo space
$markupDark : string
  markup substitute for dark (CSS value)
$markupLight : string
  markup substitute for light (CSS value)
$maskPattern : int
  Mask Pattern to use (no value in using, mostly for unit testing purposes)
$moduleValues : array<string|int, mixed>|null
  Module values map
$outputInterface : string|null
  the FQCN of the custom QROutputInterface if $outputType is set to QRCode::OUTPUT_CUSTOM
$outputType : string
  The output type
$pngCompression : int
$quietzoneSize : int
  Size of the quiet zone
$readerGrayscale : bool
  grayscale the image before reading
$readerIncreaseContrast : bool
  increase the contrast before reading
$readerUseImagickIfAvailable : bool
  use Imagick (if available) when reading QR Codes
$returnResource : bool
  Return the image resource instead of a render if applicable.
$scale : int
  size of a QR code pixel [SVG, IMAGE_*], HTML via CSS
$svgDefs : string
  anything between <defs>
$svgHeight : string|null
  optional "height" attribute with the specified value (note that the value is not checked!)
$svgOpacity : float
  SVG opacity
$svgPreserveAspectRatio : string
$svgViewBoxSize : int|null
  SVG viewBox size. a single integer number which defines width/height of the viewBox attribute.
$svgWidth : string|null
  optional "width" attribute with the specified value (note that the value is not checked!)
$textDark : string
  string substitute for dark
$textLight : string
  string substitute for light
$version : int
  QR Code version number
$versionMax : int
  Maximum QR version
$versionMin : int
  Minimum QR version
clampLogoSpaceValue() : int|null
  clamp the logo space values between 0 and maximum length (177 modules at version 40)
set_circleRadius() : void
  clamp/set SVG circle radius
set_eccLevel() : void
  sets the error correction level
set_fpdfMeasureUnit() : void
  sets the FPDF measurement unit
set_imageTransparencyBG() : void
  sets the transparency background color
set_logoSpaceHeight() : void
  clamp/set logo space height
set_logoSpaceStartX() : void
  clamp/set horizontal logo space start
set_logoSpaceStartY() : void
  clamp/set vertical logo space start
set_logoSpaceWidth() : void
  clamp/set logo space width
set_maskPattern() : void
  sets/clamps the mask pattern
set_quietzoneSize() : void
  sets/clamps the quiet zone size
set_readerUseImagickIfAvailable() : void
  enables Imagick for the QR Code reader if the extension is available
set_version() : void
  sets/clamps the version number
set_versionMax() : void
  sets the maximum version number
set_versionMin() : void
  sets the minimum version number
setMinMaxVersion() : void
  clamp min/max version number

### Properties

#### $addLogoSpace

QROptionsTrait.php : 334

Toggles logo space creation

`protected bool $addLogoSpace = false`

#### $addQuietzone

QROptionsTrait.php : 67

Add a "quiet zone" (margin) according to the QR code spec

`protected bool $addQuietzone = true`

##### Tags

see
  https://www.qrcode.com/en/howto/code.html

#### $bgColor

QROptionsTrait.php : 270

Sets the image background color (if applicable)

`protected mixed|null $bgColor = null`

- Imagick: defaults to "transparent" or "white", depending on $imageTransparent, ImagickPixel::__construct()
- GdImage: defaults to $imageTransparencyBG, QROptions::$imageTransparencyBG

#### $cachefile

QROptionsTrait.php : 99

/path/to/cache.file

`protected string|null $cachefile = null`

please note that the $file parameter in QRCode::render*() takes precedence over the $cachefile value

#### $circleRadius

QROptionsTrait.php : 186

specifies the radius of the modules when $svgDrawCircularModules is set to true

`protected float $circleRadius = 0.45`

#### $connectPaths

QROptionsTrait.php : 162

whether to connect the paths for the several module types to avoid weird glitches when using gradients etc.

`protected bool $connectPaths = false`

##### Tags

see
  https://github.com/chillerlan/php-qrcode/issues/57

#### $cssClass

QROptionsTrait.php : 114

a common css class

`protected string $cssClass = 'qrcode'`

#### $drawCircularModules

QROptionsTrait.php : 181

specify whether to draw the modules as filled circles

`protected bool $drawCircularModules = false`

a note for GDImage output:

if QROptions::$scale is less or equal than 20, the image will be upscaled internally, then the modules will be drawn using imagefilledellipse() and then scaled back to the expected size using IMG_BICUBIC which in turn produces unexpected outcomes in combination with transparency - to avoid this, set scale to a value greater than 20.

##### Tags

see
  https://github.com/chillerlan/php-qrcode/issues/23
see
  https://github.com/chillerlan/php-qrcode/discussions/122

#### $drawLightModules

QROptionsTrait.php : 249

whether to draw the light (false) modules

`protected bool $drawLightModules = true`

#### $eccLevel

QROptionsTrait.php : 53

Error correct level

`protected int $eccLevel = \chillerlan\QRCode\Common\EccLevel::L`

QRCode::ECC_X where X is:

- L => 7%
- M => 15%
- Q => 25%
- H => 30%

#### $eol

QROptionsTrait.php : 104

newline string [HTML, SVG, TEXT]

`protected string $eol = PHP_EOL`

#### $excludeFromConnect

QROptionsTrait.php : 167

specify which paths/patterns to exclude from connecting if $svgConnectPaths is set to true

`protected array<string|int, mixed> $excludeFromConnect = []`

#### $fpdfMeasureUnit

QROptionsTrait.php : 304

Measurement unit for FPDF output: pt, mm, cm, in (defaults to "pt")

`protected string $fpdfMeasureUnit = 'pt'`

##### Tags

see
  FPDF::__construct()

#### $imageBase64

QROptionsTrait.php : 232

toggle base64 or raw image data

`protected bool $imageBase64 = true`

#### $imageTransparencyBG

QROptionsTrait.php : 260

Sets the background color in GD mode: [R, G, B].

`protected array<string|int, mixed> $imageTransparencyBG = [255, 255, 255]`

When $imageTransparent is set to true, this color is set as transparent in imagecolortransparent()

##### Tags

see
  QRGdImage
see
  QROptions::$imageTransparent
see
  imagecolortransparent()

#### $imageTransparent

QROptionsTrait.php : 242

toggle background transparency

`protected bool $imageTransparent = true`

- GdImage: (png, gif) it sets imagecolortransparent() with QROptions::$imageTransparencyBG

##### Tags

see
  https://github.com/chillerlan/php-qrcode/discussions/121

#### $imagickBG

QROptionsTrait.php : 297

Imagick background color

`protected string|null $imagickBG = null`

##### Tags

deprecated
  5.0.0

  use QROptions::$bgColor instead

see
  QROptions::$bgColor
see
  ImagickPixel::__construct()

#### $imagickFormat

QROptionsTrait.php : 288

Imagick output format

`protected string $imagickFormat = 'png32'`

##### Tags

see
  Imagick::setImageFormat()
see
  https://www.imagemagick.org/script/formats.php

#### $jpegQuality

QROptionsTrait.php : 280
`protected int $jpegQuality = 85`

##### Tags

see
  imagejpeg()

#### $keepAsSquare

QROptionsTrait.php : 191

specifies which module types to exclude when $svgDrawCircularModules is set to true

`protected array<string|int, mixed> $keepAsSquare = []`

#### $logoSpaceHeight

QROptionsTrait.php : 348

height of the logo space

`protected int|null $logoSpaceHeight = null`

if only either $logoSpaceWidth or $logoSpaceHeight is given, the logo space is assumed a square of that size

#### $logoSpaceStartX

QROptionsTrait.php : 353

optional horizontal start position of the logo space (top left corner)

`protected int|null $logoSpaceStartX = null`

#### $logoSpaceStartY

QROptionsTrait.php : 358

optional vertical start position of the logo space (top left corner)

`protected int|null $logoSpaceStartY = null`

#### $logoSpaceWidth

QROptionsTrait.php : 341

width of the logo space

`protected int|null $logoSpaceWidth = null`

if only either $logoSpaceWidth or $logoSpaceHeight is given, the logo space is assumed a square of that size

#### $markupDark

QROptionsTrait.php : 206

markup substitute for dark (CSS value)

`protected string $markupDark = '#000'`

#### $markupLight

QROptionsTrait.php : 211

markup substitute for light (CSS value)

`protected string $markupLight = '#fff'`

#### $maskPattern

QROptionsTrait.php : 60

Mask Pattern to use (no value in using, mostly for unit testing purposes)

`protected int $maskPattern = \chillerlan\QRCode\Common\MaskPattern::AUTO`

[0...7] or MaskPattern::PATTERN_AUTO

#### $moduleValues

QROptionsTrait.php : 312

Module values map

`protected array<string|int, mixed>|null $moduleValues = null`

- HTML, IMAGICK: #ABCDEF, cssname, rgb(), rgba()...
- IMAGE: [63, 127, 255] // R, G, B

#### $outputInterface

QROptionsTrait.php : 92

the FQCN of the custom QROutputInterface if $outputType is set to QRCode::OUTPUT_CUSTOM

`protected string|null $outputInterface = null`

#### $outputType

QROptionsTrait.php : 87

The output type

`protected string $outputType = \chillerlan\QRCode\Output\QROutputInterface::MARKUP_SVG`

- QROutputInterface::MARKUP_XXXX where XXXX = HTML, SVG
- QROutputInterface::GDIMAGE_XXX where XXX = PNG, GIF, JPG
- QROutputInterface::STRING_XXXX where XXXX = TEXT, JSON
- QROutputInterface::IMAGICK
- QROutputInterface::EPS
- QROutputInterface::FPDF
- QROutputInterface::CUSTOM

#### $pngCompression

QROptionsTrait.php : 275
`protected int $pngCompression = -1`

##### Tags

see
  imagepng()

#### $quietzoneSize

QROptionsTrait.php : 74

Size of the quiet zone

`protected int $quietzoneSize = 4`

internally clamped to [0 ... $moduleCount / 2], defaults to 4 modules

#### $readerGrayscale

QROptionsTrait.php : 322

grayscale the image before reading

`protected bool $readerGrayscale = false`

#### $readerIncreaseContrast

QROptionsTrait.php : 329

increase the contrast before reading

`protected bool $readerIncreaseContrast = false`

note that applying contrast works different in GD and Imagick, so mileage may vary

#### $readerUseImagickIfAvailable

QROptionsTrait.php : 317

use Imagick (if available) when reading QR Codes

`protected bool $readerUseImagickIfAvailable = false`

#### $returnResource

QROptionsTrait.php : 227

Return the image resource instead of a render if applicable.

`protected bool $returnResource = false`

This option overrides other output options, such as $cachefile and $imageBase64.

Supported by the following modules:

- QRImage: resource (PHP < 8), GdImage
- QRImagick: Imagick
- QRFpdf: FPDF

##### Tags

see
  QROutputInterface::dump()

#### $scale

QROptionsTrait.php : 109

size of a QR code pixel [SVG, IMAGE_*], HTML via CSS

`protected int $scale = 5`

#### $svgDefs

QROptionsTrait.php : 126

anything between <defs>

`protected string $svgDefs = ''`

##### Tags

see
  https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs

#### $svgHeight

QROptionsTrait.php : 155

optional "height" attribute with the specified value (note that the value is not checked!)

`protected string|null $svgHeight = null`

##### Tags

see
  https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/height

#### $svgOpacity

QROptionsTrait.php : 119

SVG opacity

`protected float $svgOpacity = 1.0`

#### $svgPreserveAspectRatio

QROptionsTrait.php : 141
`protected string $svgPreserveAspectRatio = 'xMidYMid'`

##### Tags

see
  https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio

#### $svgViewBoxSize

QROptionsTrait.php : 136

SVG viewBox size. a single integer number which defines width/height of the viewBox attribute.

`protected int|null $svgViewBoxSize = null`

viewBox="0 0 x x"

##### Tags

see
  https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox
see
  https://css-tricks.com/scale-svg/#article-header-id-3

#### $svgWidth

QROptionsTrait.php : 148

optional "width" attribute with the specified value (note that the value is not checked!)

`protected string|null $svgWidth = null`

##### Tags

see
  https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/width

#### $textDark

QROptionsTrait.php : 196

string substitute for dark

`protected string $textDark = '🔴'`

#### $textLight

QROptionsTrait.php : 201

string substitute for light

`protected string $textLight = '⭕'`

#### $version

QROptionsTrait.php : 29

QR Code version number

`protected int $version = \chillerlan\QRCode\Common\Version::AUTO`

[1 ... 40] or Version::AUTO

#### $versionMax

QROptionsTrait.php : 41

Maximum QR version

`protected int $versionMax = 40`

#### $versionMin

QROptionsTrait.php : 36

Minimum QR version

`protected int $versionMin = 1`

if $version = QRCode::VERSION_AUTO

### Methods

#### clampLogoSpaceValue()

QROptionsTrait.php : 485

clamp the logo space values between 0 and maximum length (177 modules at version 40)

`protected clampLogoSpaceValue(int|null $value) : int|null`

##### Parameters

$value : int|null

##### Return values

int|null —

#### set_circleRadius()

QROptionsTrait.php : 525

clamp/set SVG circle radius

`protected set_circleRadius(float $circleRadius) : void`

##### Parameters

$circleRadius : float

##### Return values

void —

#### set_eccLevel()

QROptionsTrait.php : 400

sets the error correction level

`protected set_eccLevel(int $eccLevel) : void`

##### Parameters

$eccLevel : int

##### Tags

todo:

  accept string values (PHP8+)

see
  https://github.com/chillerlan/php-qrcode/discussions/160
throws
  QRCodeException

##### Return values

void —

#### set_fpdfMeasureUnit()

QROptionsTrait.php : 465

sets the FPDF measurement unit

`protected set_fpdfMeasureUnit(string $unit) : void`

##### Parameters

$unit : string

##### Tags

codeCoverageIgnore

##### Return values

void —

#### set_imageTransparencyBG()

QROptionsTrait.php : 432

sets the transparency background color

`protected set_imageTransparencyBG(array<string|int, mixed> $imageTransparencyBG) : void`

##### Parameters

$imageTransparencyBG : array<string|int, mixed>

##### Tags

throws
  QRCodeException

##### Return values

void —

#### set_logoSpaceHeight()

QROptionsTrait.php : 504

clamp/set logo space height

`protected set_logoSpaceHeight(int|null $value) : void`

##### Parameters

$value : int|null

##### Return values

void —

#### set_logoSpaceStartX()

QROptionsTrait.php : 511

clamp/set horizontal logo space start

`protected set_logoSpaceStartX(int|null $value) : void`

##### Parameters

$value : int|null

##### Return values

void —

#### set_logoSpaceStartY()

QROptionsTrait.php : 518

clamp/set vertical logo space start

`protected set_logoSpaceStartY(int|null $value) : void`

##### Parameters

$value : int|null

##### Return values

void —

#### set_logoSpaceWidth()

QROptionsTrait.php : 497

clamp/set logo space width

`protected set_logoSpaceWidth(int|null $value) : void`

##### Parameters

$value : int|null

##### Return values

void —

#### set_maskPattern()

QROptionsTrait.php : 412

sets/clamps the mask pattern

`protected set_maskPattern(int $maskPattern) : void`

##### Parameters

$maskPattern : int

##### Return values

void —

#### set_quietzoneSize()

QROptionsTrait.php : 423

sets/clamps the quiet zone size

`protected set_quietzoneSize(int $quietzoneSize) : void`

##### Parameters

$quietzoneSize : int

##### Return values

void —

#### set_readerUseImagickIfAvailable()

QROptionsTrait.php : 478

enables Imagick for the QR Code reader if the extension is available

`protected set_readerUseImagickIfAvailable(bool $useImagickIfAvailable) : void`

##### Parameters

$useImagickIfAvailable : bool

##### Return values

void —

#### set_version()

QROptionsTrait.php : 388

sets/clamps the version number

`protected set_version(int $version) : void`

##### Parameters

$version : int

##### Return values

void —

#### set_versionMax()

QROptionsTrait.php : 381

sets the maximum version number

`protected set_versionMax(int $version) : void`

##### Parameters

$version : int

##### Return values

void —

#### set_versionMin()

QROptionsTrait.php : 374

sets the minimum version number

`protected set_versionMin(int $version) : void`

##### Parameters

$version : int

##### Return values

void —

#### setMinMaxVersion()

QROptionsTrait.php : 363

clamp min/max version number

`protected setMinMaxVersion(int $versionMin, int $versionMax) : void`

##### Parameters

$versionMin : int
$versionMax : int

##### Return values

void —

## Search results