chillerlan/php-qrcode
Generate and read QR codes in PHP. Supports Model 2 QR codes (versions 1–40), ECC levels L/M/Q/H, mixed encoding modes, and multiple output formats. Includes a QR code reader based on a PHP port of ZXing.
A QR code (quick-response code), sometimes referred to as QR symbol or simply just symbol, is a type of two-dimensional matrix barcode, invented in 1994 by Japanese company Denso Wave for labelling automobile parts. The QR labelling system was applied beyond the automobile industry due to its fast readability and greater storage capacity compared to standard UPC barcodes. QR Codes, more specifically, the popular Model 2, are internationally standardized in the ISO/IEC 18004.
A QR symbol is arranged in a matrix consisting of an array of nominally square modules arranged in an overall square pattern.
For ease of reference, module positions are defined by their row and column coordinates in the symbol, in the form (x, y)
where x designates the column (counting from left to right) and y the row (counting from the top downwards) in which
the module is located, with counting commencing at 0. Module (0, 0) is therefore located in the upper left corner of the symbol.
A module represents a single square "pixel" in the matrix (not to confuse with pixels in a raster image or screen). A dark module represents a binary one and a light module represents a binary zero.
The version of a QR symbol determines the side length of the matrix (and therefore the maximum capacity of code words),
ranging from 21×21 modules (441 total) at version 1 to 177×177 modules (31329 total) at version 40.
The module count increases in steps of 4 and can be calculated by 4 * version + 17.
The maximum capacity for each version, mode and ECC level can be found in this table (qrcode.com).
The Finder Pattern shall consist of three identical Position Detection Patterns located at the upper left, upper right and lower left corners of the symbol.
Each Position Detection Pattern may be viewed as three superimposed concentric squares and is constructed of dark 7×7 modules, light 5×5 modules and dark 3×3 modules.
The symbol is preferentially encoded so that similar patterns have a low probability of being encountered elsewhere in the symbol, enabling rapid identification of a possible QR Code symbol in the field of view. Identification of the three Position Detection Patterns comprising the finder pattern then unambiguously defines the location and orientation of the symbol in the field of view.
The Alignment Pattern is a fixed reference pattern in defined positions, which enables the decode software to resynchronise the coordinate mapping of the modules in the event of moderate amounts of distortion of the image.
Each Alignment Pattern may be viewed as three superimposed concentric squares and is constructed of dark 5×5 modules, light 3×3 modules and a single central dark module.
The number of Alignment Patterns depends on the symbol version, and they shall be placed in all Model 2 symbols of version 2 or larger in positions defined in the specification.
The horizontal and vertical Timing Patterns respectively consist of a one module wide row or column of alternating dark and light modules, commencing and ending with a dark module. The horizontal Timing Pattern runs across row 6 of the symbol between the separators for the upper Position Detection Patterns; the vertical Timing Pattern similarly runs down column 6 of the symbol between the separators for the left-hand Position Detection Patterns. They enable the symbol density and version to be determined and provide datum positions for determining module coordinates.
A pattern of all light modules, one module wide, separating the Position Detection Patterns from the rest of the symbol.
This is a region 4 modules wide which shall be free of all other markings, surrounding the symbol on all four sides. Its nominal reflectance value shall be equal to that of the light modules.
This region shall contain the symbol characters representing data, those representing error correction codewords, the Version Information and Format Information.
This region contains the encoded data and error correction code blocks. Data bits are placed starting at the bottom-right of the matrix and proceeding upward in a column that is 2 modules wide. When the column reaches the top, the next 2-module column starts immediately to the left of the previous column and continues downward. Whenever the current column reaches the edge of the matrix, move on to the next 2-module column and change direction. If a function pattern or reserved area is encountered, the data bit is placed in the next unused module. (see wikipedia QR code - Encoding and thonky.com - QR Code Tutorial)
The Version Information is an 18 bit sequence containing 6 data bits, with 12 error correction bits calculated using the (18, 6) BCH code which contains the version number.
The Format Information is a 15 bit sequence containing 5 data bits, with 10 error correction bits calculated using the (15, 5) BCH code. It contains information on the error correction level applied to the symbol and on the masking pattern used, essential to enable the remainder of the encoding region to be decoded.
The module in position (4 * version + 9, 8) shall always be dark and does not form part of the Format Information.
How can I help you explore Laravel packages today?