QRCoders.jl Documentation

Module that can create QR codes as data or images using qrcode or exportqrcode.

Creating QR codes

QRCoders.qrcodeFunction
qrcode(message::AbstractString;
       eclevel = Medium(),
       version = 0,
       mode::Union{Nothing, Mode} = nothing, 
       mask::Union{Nothing, Int} = nothing, 
       compact::Bool = true,
       width::Int = 4)

Create a BitArray{2} with the encoded message, with true (1) for the black areas and false (0) as the white ones. 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 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.exportqrcodeFunction
exportqrcode( message::AbstractString
            , path::AbstractString = "qrcode.png"
            ; eclevel::ErrCorrLevel = Medium()
            , version::Int = 0
            , mode::Union{Nothing, Mode} = nothing
            , targetsize::Int = 5
            , compact::Bool = false )

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.getversionFunction
getversion(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.getmodeFunction
getmode(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.ModeType

Abstract type that groups the five supported encoding modes Numeric, Alphanumeric, Byte, Kanji and UTF8.

QRCoders.AlphanumericType

Encoding mode for messages composed of digits, characters A-Z (capital only) , space and % * + - . / : $.

QRCoders.ByteType

Encoding 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.ErrCorrLevelType

Abstract type that groups the four error correction levels Low, Medium, Quartile and High.

QRCoders.LowType

Error correction level that can restore up to 7% of missing codewords.

QRCoders.MediumType

Error correction level that can restore up to 15% of missing codewords.

QRCoders.QuartileType

Error correction level that can restore up to 25% of missing codewords.

QRCoders.HighType

Error correction level that can restore up to 30% of missing codewords.