diff --git a/Appendix/Contribute.html b/Appendix/Contribute.html index c2d46c528..cecbb4d33 100644 --- a/Appendix/Contribute.html +++ b/Appendix/Contribute.html @@ -82,17 +82,23 @@
The QR Code matrix is a 2-dimensional array of numerical values that hold a bit mask for +
The QR Code matrix is a 2-dimensional array of numerical values that hold a bitmask for
each QR pixel (“module” as per specification), the so-called “module type” or $M_TYPE, which is represented by
the QRMatrix::M_* constants.
+The bitmask is 12 bits wide; the first 11 bits stand for the pattern type, the highest bit designates whether the module is dark or light.
You can assign different values for the several function patterns to colorize them or even draw pixel-art.
QROutputInterface, it may be necessary to overwrite the
default values,
that are replaced by the user defined values in QROptions::$moduleValues during the render process.
-The map of QRMatrix::M_* constants => default values looks similar to the following:
The map of QRMatrix::M_* constants => default values looks similar to the following
+(values with “_DARK” and “_LIGHT” suffix are for convenience):
$options->moduleValues = [
// light
- QRMatrix::M_NULL => false,
- QRMatrix::M_DARKMODULE_LIGHT => false,
+ QRMatrix::M_NULL => false, // special value - always 0
+ QRMatrix::M_DARKMODULE_LIGHT => false, // key equivalent to (QRMatrix::M_DARKMODULE & ~QRMatrix::IS_DARK)
QRMatrix::M_DATA => false,
QRMatrix::M_FINDER => false,
QRMatrix::M_SEPARATOR => false,
@@ -344,10 +352,9 @@ that are replaced by the user defined values in QRMatrix::M_QUIETZONE => false,
QRMatrix::M_LOGO => false,
QRMatrix::M_FINDER_DOT_LIGHT => false,
- QRMatrix::M_TEST => false,
// dark
QRMatrix::M_DARKMODULE => true,
- QRMatrix::M_DATA_DARK => true,
+ QRMatrix::M_DATA_DARK => true, // key equivalent to (QRMatrix::M_DATA | QRMatrix::IS_DARK)
QRMatrix::M_FINDER_DARK => true,
QRMatrix::M_SEPARATOR_DARK => true,
QRMatrix::M_ALIGNMENT_DARK => true,
@@ -357,7 +364,6 @@ that are replaced by the user defined values in QRMatrix::M_QUIETZONE_DARK => true,
QRMatrix::M_LOGO_DARK => true,
QRMatrix::M_FINDER_DOT => true,
- QRMatrix::M_TEST_DARK => true,
];
The settings can be saved to and loaded from JSON, e.g. to store them in a database:
$json = $options->toJSON(JSON_THROW_ON_ERROR);
// via JsonSerializable interface
@@ -424,16 +430,6 @@ After invocation of the $qrcode->setOptions($options);
You can specify an output file path in which the QR Code content is stored (this will override the QROptions::$cachefile
-setting, see common output options):
$qrcode->render($data, '/path/to/qrcode.svg');
-
-printf('<img src="%s" alt="QR Code" />', '/path/to/qrcode.svg');
-QRMatrix instanceYou can render a QRMatrix instance directly:
The QRMatrix object from the DecoderResult can be reused:
You can specify an output file path in which the QR Code content is stored:
+$options->outputBase64 = false;
+$options->cachefile = '/path/to/qrcode.svg';
+
+$qrcode->render($data);
+
+printf('<img src="%s" alt="QR Code" />', $options->cachefile);
+The file path can also be supplied as second parameter to the render methods (this will override the QROptions::$cachefile setting):
$qrcode->render($data, '/path/to/qrcode.svg');
+By default, a Base64 encoded data URI will be returned (where applicable):
+echo $qrcode->render($data); // -> data:image/png;base64,...
+Disable Base64 output:
+$options->outputBase64 = false;
+
+header('Content-type: image/png');
+
+echo $qrcode->render($data);
+In some cases you might want to modify the QR image after creation (without crating a custom output class), in which case you want the internal image resource rather than the final output.
+$options->outputType = QROutputInterface::IMAGICK;
+$options->returnResource = true;
+
+/** @var Imagick $imagick */
+$imagick = $qrcode->render($data);
+
+echo $imagick->getImageBlob();
+$options->addLogoSpace = true;
+$options->logoSpaceWidth = 9;
+$options->logoSpaceHeight = 9;
+$options->logoSpaceStartX = 10;
+$options->logoSpaceStartY = 10;
+
Terminal
To install php-qrcode on the terminal, use:
-composer require chillerlan/php-qrcode
+composer require chillerlan/php-qrcode
+
+
If you want to install the package from a specific tag or commit, do as follows:
-
-composer require chillerlan/php-qrcode:4.3.4
-composer require chillerlan/php-qrcode:dev-main#f15b0afe9d4128bf734c3bf1bcffae72bf7b3e53
-
+composer require chillerlan/php-qrcode:4.3.4
+composer require chillerlan/php-qrcode:dev-main#f15b0afe9d4128bf734c3bf1bcffae72bf7b3e53
+
+
diff --git a/Usage/Overview.html b/Usage/Overview.html
index 726559de8..8a139a805 100644
--- a/Usage/Overview.html
+++ b/Usage/Overview.html
@@ -82,17 +82,23 @@
- Advanced usage
- Configuration settings
+
Articles:
diff --git a/Usage/Quickstart.html b/Usage/Quickstart.html index b5e61baea..0556c8c99 100644 --- a/Usage/Quickstart.html +++ b/Usage/Quickstart.html @@ -82,17 +82,23 @@$data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';
$qrcode = (new QRCode)->render($data);
+// default output is a base64 encoded data URI
printf('<img src="%s" alt="QR Code" />', $qrcode);
See Advanced usage for a more in-depth usage guide. +
See Advanced usage for a more in-depth usage guide +and configuration settings for a list of available options. Also, have a look in the examples folder for some more usage examples.
@@ -356,17 +364,16 @@ Also, have a looktry{
$result = (new QRCode)->readFromFile('path/to/file.png'); // -> DecoderResult
+
+ // you can now use the result instance...
+ $content = $result->data;
+
+ // ...or simply cast the result instance to string to get the content
+ $content = (string)$result;
}
catch(Throwable $exception){
// handle exception...
- // throw ...
}
-
-// you can now use the result instance...
-$content = $result->data;
-
-// ...or simply cast the result instance to string to get the content
-$content = (string)$result;
It’s generally a good idea to wrap the reading in a try/catch block to handle any errors that may occur in the process.
diff --git a/_sources/Customizing/Module-Values.md.txt b/_sources/Customizing/Module-Values.md.txt index d25de444e..c758434b4 100644 --- a/_sources/Customizing/Module-Values.md.txt +++ b/_sources/Customizing/Module-Values.md.txt @@ -2,9 +2,10 @@ ## Basics -The QR Code matrix is a 2-dimensional array of numerical values that hold a bit mask for +The QR Code matrix is a 2-dimensional array of numerical values that hold a bitmask for each QR pixel ("module" as per specification), the so-called "module type" or `$M_TYPE`, which is represented by [the `QRMatrix::M_*` constants](https://chillerlan.github.io/php-qrcode/classes/chillerlan-QRCode-Data-QRMatrix.html#toc-constants). +The bitmask is 12 bits wide; the first 11 bits stand for the pattern type, the highest bit designates whether the module is dark or light. You can assign different values for the several [function patterns](../Appendix/Terminology.md#function-patterns) to colorize them or even draw pixel-art. @@ -14,13 +15,14 @@ To map the values and properly render the modules for the given `QROutputInterfa [default values](https://chillerlan.github.io/php-qrcode/classes/chillerlan-QRCode-Output-QROutputInterface.html#constant_DEFAULT_MODULE_VALUES), that are replaced by the user defined values in `QROptions::$moduleValues` during the render process. -The map of `QRMatrix::M_*` constants => default values looks similar to the following: +The map of `QRMatrix::M_*` constants => default values looks similar to the following +(values with "_DARK" and "_LIGHT" suffix are for convenience): ```php $options->moduleValues = [ // light - QRMatrix::M_NULL => false, - QRMatrix::M_DARKMODULE_LIGHT => false, + QRMatrix::M_NULL => false, // special value - always 0 + QRMatrix::M_DARKMODULE_LIGHT => false, // key equivalent to (QRMatrix::M_DARKMODULE & ~QRMatrix::IS_DARK) QRMatrix::M_DATA => false, QRMatrix::M_FINDER => false, QRMatrix::M_SEPARATOR => false, @@ -31,10 +33,9 @@ $options->moduleValues = [ QRMatrix::M_QUIETZONE => false, QRMatrix::M_LOGO => false, QRMatrix::M_FINDER_DOT_LIGHT => false, - QRMatrix::M_TEST => false, // dark QRMatrix::M_DARKMODULE => true, - QRMatrix::M_DATA_DARK => true, + QRMatrix::M_DATA_DARK => true, // key equivalent to (QRMatrix::M_DATA | QRMatrix::IS_DARK) QRMatrix::M_FINDER_DARK => true, QRMatrix::M_SEPARATOR_DARK => true, QRMatrix::M_ALIGNMENT_DARK => true, @@ -44,7 +45,6 @@ $options->moduleValues = [ QRMatrix::M_QUIETZONE_DARK => true, QRMatrix::M_LOGO_DARK => true, QRMatrix::M_FINDER_DOT => true, - QRMatrix::M_TEST_DARK => true, ]; ``` diff --git a/_sources/Usage/Advanced-usage.md.txt b/_sources/Usage/Advanced-usage.md.txt index 725bf9c41..07122d0ed 100644 --- a/_sources/Usage/Advanced-usage.md.txt +++ b/_sources/Usage/Advanced-usage.md.txt @@ -39,7 +39,7 @@ $options->fromIterable($myOptions); ``` -### Load and save JSON +### Load and save options from/to JSON The settings can be saved to and loaded from JSON, e.g. to store them in a database: @@ -122,18 +122,6 @@ $qrcode->setOptions($options); ``` -### Save to file - -You can specify an output file path in which the QR Code content is stored (this will override the `QROptions::$cachefile` -setting, see [common output options](../Customizing/Common.md#save-to-file)): - -```php -$qrcode->render($data, '/path/to/qrcode.svg'); - -printf('User manual for chillerlan/php-qrcode [main]. Updated on Oct 04, 2023.
+User manual for chillerlan/php-qrcode [main]. Updated on Oct 07, 2023.
The phpDocumentor API documentation can be found at chillerlan.github.io/php-qrcode.
This work is licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) License.