API-QROptions.md.txt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # QROptions
  2. (via `QROptionsTrait`)
  3. The full phpDocumentor API documentation can be found at [chillerlan.github.io/php-qrcode](https://chillerlan.github.io/php-qrcode/classes/chillerlan-QRCode-QROptions.html).
  4. ## Methods
  5. Inherited from [`SettingsContainerAbstract`](https://github.com/chillerlan/php-settings-container/blob/main/src/SettingsContainerAbstract.php)
  6. <!-- using non-breaking spaces chr(255) in the longest method signature to force the silly table to stretch -->
  7. | method | return | info |
  8. |--------------------------------------------|------------------------------|-----------------------------------------------------------------------------------------------------------------|
  9. | `__construct(iterable $properties = null)` | - | calls `construct()` internally after the properties have been set |
  10. | (protected) `construct()` | `void` | calls a method with trait name as replacement constructor for each used trait (similar to PHP4 constructors) |
  11. | `__get(string $property)` | `mixed` | calls `$this->{'get_'.$property}()` if such a method exists |
  12. | `__set(string $property, $value)` | `void` | calls `$this->{'set_'.$property}($value)` if such a method exists |
  13. | `__isset(string $property)` | `bool` | |
  14. | `__unset(string $property)` | `void` | |
  15. | `__toString()` | `string` | a JSON string |
  16. | `toArray()` | `array` | |
  17. | `fromIterable(iterable $properties)` | `SettingsContainerInterface` | |
  18. | `toJSON(int $jsonOptions = null)` | `string` | accepts [JSON options constants](http://php.net/manual/json.constants.php) |
  19. | `fromJSON(string $json)` | `SettingsContainerInterface` | |
  20. | `jsonSerialize()` | `mixed` | implements the [`JsonSerializable`](https://www.php.net/manual/en/jsonserializable.jsonserialize.php) interface |
  21. ## Properties
  22. | property | type | default | allowed | description |
  23. |--------------------------------|----------------|---------------------------------|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
  24. | `$version` | `int` | `Version::AUTO` | `1...40`, `Version::AUTO` | [QR Code version number](http://www.qrcode.com/en/about/version.html) |
  25. | `$versionMin` | `int` | `1` | `1...40` | Minimum QR version (if `$version = QRCode::VERSION_AUTO`) |
  26. | `$versionMax` | `int` | `40` | `1...40` | Maximum QR version (if `$version = QRCode::VERSION_AUTO`) |
  27. | `$eccLevel` | `int` | `EccLevel::L` | `EccLevel::X` | Error correct level, where X = L (7%), M (15%), Q (25%), H (30%) |
  28. | `$maskPattern` | `int` | `MaskPattern::AUTO` | `0...7`, `MaskPattern::AUTO` | Mask Pattern to use |
  29. | `$addQuietzone` | `bool` | `true` | * | Add a "quiet zone" (margin) according to the QR code spec |
  30. | `$quietzoneSize` | `int` | `4` | clamped to `0...($matrixSize / 2)` | Size of the quiet zone |
  31. | `$outputType` | `string` | `QROutputInterface::MARKUP_SVG` | `QROutputInterface::XXX` | The built-in output type, XXX can be one of: `MARKUP_HTML`, `MARKUP_SVG`, `GDIMAGE_PNG`, `GDIMAGE_JPG`, `GDIMAGE_GIF`, `STRING_TEXT`, `STRING_JSON`, `IMAGICK`, `EPS`, `FPDF`, `CUSTOM` |
  32. | `$outputInterface` | `string\|null` | `null` | * | The FQCN of the custom `QROutputInterface` if `QROptions::$outputType` is set to `QROutputInterface::CUSTOM` |
  33. | `$returnResource` | `bool` | `false` | * | Return the image resource instead of a render if applicable. |
  34. | `$cachefile` | `string\|null` | `null` | * | Optional cache file path |
  35. | `$imageBase64` | `bool` | `true` | * | Toggle base64 or raw image data (if applicable) |
  36. | `$eol` | `string` | `PHP_EOL` | * | Newline string (HTML, SVG, TEXT) |
  37. | `$bgColor` | `mixed` | `null` | a valid FPDF, GD or Imagick color value | Sets the image background color (if applicable). QRImagick: defaults to "white", QRGdImage: defaults to [255, 255, 255], QRFpdf: defaults to blank internally (white page) |
  38. | `$drawLightModules` | `bool` | `true` | * | Whether to draw the light (false) modules |
  39. | `$drawCircularModules` | `bool` | `false` | * | Specify whether to draw the modules as filled circles |
  40. | `$circleRadius` | `float` | `0.45` | `0.1...0.75` | Specifies the radius of the modules when $svgDrawCircularModules is set to true |
  41. | `$keepAsSquare` | `array` | `[]` | `int[]` | Specifies which module types to exclude when $svgDrawCircularModules is set to true |
  42. | `$connectPaths` | `bool` | `false` | * | Whether to connect the paths for the several module types to avoid weird glitches when using gradients etc. |
  43. | `$excludeFromConnect` | `array` | `[]` | `int[]` | Specify which paths/patterns to exclude from connecting if $svgConnectPaths is set to true |
  44. | `$moduleValues` | `array\|null` | `null` | * | Module values map, see [[Custom module values]] |
  45. | `$addLogoSpace` | `bool` | `false` | * | Toggles logo space creation |
  46. | `$logoSpaceWidth` | `int\|null` | `null` | * | Width of the logo space |
  47. | `$logoSpaceHeight` | `int\|null` | `null` | * | Height of the logo space |
  48. | `$logoSpaceStartX` | `int\|null` | `null` | * | Optional horizontal start position of the logo space (top left corner) |
  49. | `$logoSpaceStartY` | `int\|null` | `null` | * | Optional vertical start position of the logo space (top left corner) |
  50. | `$scale` | `int` | `5` | * | Pixel size of a QR code module |
  51. | `$imageTransparent` | `bool` | `true` | * | Toggle transparency (no jpeg support), QRGdImage and QRImagick only. The given `QROptions::$transparencyColor` is set as transparent |
  52. | `$transparencyColor` | `mixed` | `null` | a valid GD or Imagick color value | Sets a transparency color for when `QROptions::$imageTransparent` is set to true. Defaults to `QROptions::$bgColor`. |
  53. | `$pngCompression` | `int` | `-1` | `-1...9` | `imagepng()` compression level, -1 = auto |
  54. | `$jpegQuality` | `int` | `85` | `0...100` | `imagejpeg()` quality |
  55. | `$imagickFormat` | `string` | `'png'` | * | ImageMagick output type, see `Imagick::setType()` |
  56. | `$cssClass` | `string` | `'qrcode'` | * | A common css class |
  57. | `$markupDark` | `string` | `'#000'` | * | Markup substitute for dark (CSS value) |
  58. | `$markupLight` | `string` | `'#fff'` | * | Markup substitute for light (CSS value) |
  59. | `$svgAddXmlHeader` | `bool` | `true` | * | Whether to add an XML header line or not, e.g. to embed the SVG directly in HTML |
  60. | `$svgOpacity` | `float` | `1.0` | `0...1` | SVG opacity |
  61. | `$svgDefs` | `string` | `''` | * | Anything in the [`<defs>`](https://developer.mozilla.org/docs/Web/SVG/Element/defs) tag |
  62. | `$svgViewBoxSize` | `int\|null` | `null` | * | SVG viewBox size. A single integer number which defines width/height of the [viewBox attribute](https://css-tricks.com/scale-svg/#article-header-id-3) `viewBox="0 0 x x"`. |
  63. | `$svgPreserveAspectRatio` | `string` | `'xMidYMid'` | * | See [preserveAspectRatio on MDN](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio) |
  64. | `$svgWidth` | `string\|null` | `null` | * | Optional "width" attribute with the specified value (note that the value is not checked!) |
  65. | `$svgHeight` | `string\|null` | `null` | * | Optional "height" attribute with the specified value (note that the value is not checked!) |
  66. | `$textDark` | `string` | `'🔴'` | * | String substitute for dark |
  67. | `$textLight` | `string` | `'⭕'` | * | String substitute for light |
  68. | `$fpdfMeasureUnit` | `string` | `'pt'` | * | Measurement unit for FPDF output: pt, mm, cm, in |
  69. | `$readerUseImagickIfAvailable` | `bool` | `false` | * | Use Imagick (if available) when reading QR Codes |
  70. | `$readerGrayscale` | `bool` | `false` | * | Grayscale the image before reading |
  71. | `$readerIncreaseContrast` | `bool` | `false` | * | Increase the contrast before reading |