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.
QRCoders.getversion
— Functiongetversion(message::AbstractString, mode::Mode, level::ErrCorrLevel)
Return the version of the QR code, between 1 and 40.
julia> getversion("Hello World!", Alphanumeric(), High())
2
QRCoders.getmode
— Functiongetmode(message::AbstractString)
Return the encoding mode of message
, either Numeric()
, Alphanumeric()
, Byte()
or Kanji().
Examples
julia> getmode("HELLO WORLD")
Alphanumeric()
julia> getmode("0123456")
Numeric()
julia> getmode("12αβ")
UTF8()
julia> getmode("茗荷")
Kanji()
Encoding modes
There are three 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)
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.