QRCoders.jl Documentation
Module that can create QR codes as data or images using qrcode
or exportqrcode
.
Creating QR codes
QRCoders.qrcode
— Functionqrcode( message::AbstractString
; eclevel::ErrCorrLevel = Medium()
, version::Int = 0
, mode::Mode = Numeric()
, mask::Int = -1
, width::Int=0)
Create a BitArray{2}
with the encoded message
, with true
(1
) for the black areas and false
(0
) as the white ones.
The error correction level eclevel
can be picked from four values: Low()
(7% of missing data can be restored), Medium()
(15%), Quartile()
(25%) or High()
(30%). Higher levels make denser QR codes.
The version of the QR code can be picked from 1 to 40. If the assigned version is too small to contain the message, the first available version is used.
The encoding mode mode
can be picked from five values: Numeric()
, Alphanumeric()
, Byte()
, Kanji()
or UTF8()
. If the assigned mode
is nothing
or failed to contain the message, the mode is automatically picked.
The mask pattern mask
can be picked from 0 to 7. If the assigned mask
is nothing
, the mask pattern will picked by the penalty rules.
QRCoders.exportqrcode
— Functionexportqrcode( message::AbstractString
, path::AbstractString = "qrcode.png"
; eclevel::ErrCorrLevel = Medium()
, version::Int = 0
, mode::Union{Nothing, Mode} = nothing
, targetsize::Int = 5
, width::int=4)
Create a PNG
file with the encoded message
of approximate size targetsize
cm. If compact
is false
, white space is added around the QR code.
The error correction level eclevel
can be picked from four values: Low()
(7% of missing data can be restored), Medium()
(15%), Quartile()
(25%) or High()
(30%). Higher levels make denser QR codes.
The version of the QR code can be picked from 1 to 40. If the assigned version is too small to contain the message, the first available version is used.
The encoding mode mode
can be picked from four values: Numeric()
, Alphanumeric()
, Byte()
, Kanji()
or UTF8()
. If the assigned mode
is nothing
or failed to contain the message, the mode is automatically picked.
The mask pattern mask
can be picked from 0 to 7. If the assigned mask
is nothing
, the mask pattern will picked by the penalty rules.
styled QR codes
Plot in REPL.
QRCoders.unicodeplot
— Functionunicodeplot(mat::AbstractMatrix{Bool}; border=:none)
Uses UnicodePlots.jl to draw the matrix.
Note: In UnicodePlots.jl, matrix index start from the left-down corner.
unicodeplot(message::AbstractString
; border=:none)
Uses UnicodePlots.jl to draw the QR code of message
.
QRCoders.unicodeplotbychar
— Functionunicodeplotbychar(mat::AbstractMatrix)
Plot of the QR code using Unicode characters.
Note that true
represents white and false
represents black.
unicodeplotbychar(message::AbstractString)
Plot of the QR code using Unicode characters.
Note that true
represents black and false
represents white in qrcode, which is the opposite of the image convention.
Encoding modes
There are five several encoding mode currently supported.
QRCoders.Mode
— TypeAbstract type that groups the five supported encoding modes Numeric
, Alphanumeric
, Byte
, Kanji
and UTF8
.
QRCoders.Numeric
— TypeEncoding mode for messages composed of digits only.
QRCoders.Alphanumeric
— TypeEncoding mode for messages composed of digits, characters A
-Z
(capital only) , space and %
*
+
-
.
/
:
$
.
QRCoders.Byte
— TypeEncoding mode for messages composed of one-byte characters(unicode range from 0x00 to 0xff, including ISO-8859-1 and undefined characters)
QRCoders.Kanji
— TypeEncoding mode for messages composed of Shift JIS(Shift Japanese Industrial Standards) characters.
QRCoders.UTF8
— TypeEncoding mode for messages composed of utf-8 characters.
Error Correction
There are four error correction levels you can choose from.
QRCoders.ErrCorrLevel
— TypeAbstract type that groups the four error correction levels Low
, Medium
, Quartile
and High
.
QRCoders.Low
— TypeError correction level that can restore up to 7% of missing codewords.
QRCoders.Medium
— TypeError correction level that can restore up to 15% of missing codewords.
QRCoders.Quartile
— TypeError correction level that can restore up to 25% of missing codewords.
QRCoders.High
— TypeError correction level that can restore up to 30% of missing codewords.