You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Round block sizes to improve readability and make the blocks sharper in pixel based outputs (like png).
62
-
// There are three approaches:
63
-
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_MARGIN); // The size of the qr code is shrinked, if necessary, but the size of the final image remains unchanged due to additional margin being added (default)
64
-
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_ENLARGE); // The size of the qr code and the final image is enlarged, if necessary
65
-
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_SHRINK); // The size of the qr code and the final image is shrinked, if necessary
66
92
67
93
// Set additional writer options (SvgWriter example)
If you use a barcode scanner you can have some troubles while reading the
120
+
generated QR codes. Depending on the encoding you chose you will have an extra
121
+
amount of data corresponding to the ECI block. Some barcode scanner are not
122
+
programmed to interpret this block of information. To ensure a maximum
123
+
compatibility you can use the `ISO-8859-1` encoding that is the default
124
+
encoding used by barcode scanners (if your character set supports it,
125
+
i.e. no Chinese characters are present).
87
126
88
-
If you use a barcode scanner you can have some troubles while reading the generated QR codes. Depending on the encoding you chose you will have an extra amount of data corresponding to the ECI block. Some barcode scanner are not programmed to interpret this block of information. For exemple the ECI block for `UTF-8` is `000026` so the above exemple will produce : `\000026Life is too short to be generating QR codes`. To ensure a maximum compatibility you can use the `ISO-8859-1` encoding that is the default encoding used by barcode scanners.
127
+
### Round block size mode
128
+
129
+
By default block sizes are rounded to guarantee sharp images and improve
130
+
readability. However some other rounding variants are available.
131
+
132
+
* RoundBlockSizeModeMargin (default): the size of the QR code is shrunk if
133
+
necessary but the size of the final image remains unchanged due to additional
134
+
margin being added.
135
+
* RoundBlockSizeModeEnlarge: the size of the QR code and the final image are
136
+
enlarged when rounding differences occur.
137
+
* RoundBlockSizeModeShrink: the size of the QR code and the final image are
138
+
shrunk when rounding differences occur.
139
+
* RoundBlockSizeModeNone: No rounding.
89
140
90
141
## Readability
91
142
@@ -95,24 +146,25 @@ can tweak these parameters if you are looking for optimal results. You can also
95
146
check $qrCode->getRoundBlockSize() value to see if block dimensions are rounded
96
147
so that the image is more sharp and readable. Please note that rounding block
97
148
size can result in additional padding to compensate for the rounding difference.
149
+
And finally the encoding (default UTF-8 to support large character sets) can be
150
+
set to `ISO-8859-1` if possible to improve readability.
98
151
99
152
## Built-in validation reader
100
153
101
154
You can enable the built-in validation reader (disabled by default) by calling
102
155
setValidateResult(true). This validation reader does not guarantee that the QR
103
156
code will be readable by all readers but it helps you provide a minimum level
104
-
of quality.
105
-
106
-
Take note that the validator can consume quite amount of additional resources.
157
+
of quality. Take note that the validator can consume quite amount of additional
158
+
resources and it should be installed separately only if you use it.
107
159
108
160
## Symfony integration
109
161
110
162
The [endroid/qr-code-bundle](https://github.com/endroid/qr-code-bundle)
111
163
integrates the QR code library in Symfony for an even better experience.
112
164
113
165
* Configure your defaults (like image size, default writer etc.)
114
-
*Generate QR codes quickly from anywhere via the factory service
115
-
* Generate QR codes directly by typing an URL like /qr-code/\<text>.png?size=300
166
+
*Support for multiple configurations and injection via aliases
167
+
* Generate QR codes for defined configurations via URL like /qr-code/<config>/Hello
116
168
* Generate QR codes or URLs directly from Twig using dedicated functions
117
169
118
170
Read the [bundle documentation](https://github.com/endroid/qr-code-bundle)
0 commit comments