QRCode.jl

The original version of https://github.com/JuliaImages/QRCoders.jl written by jiegillet
Author JuliaImages
Popularity
3 Stars
Updated Last
1 Year Ago
Started In
August 2022

QRCode

New development goes to QRCoders

Create QR Codes as data within Julia, or export as PNG.

Create a QR Code as data

Creating a QR Code couldn't be simpler.

julia> using QRCode

julia> qrcode("Hello world!")
29×29 BitArray{2}:
 false  false  false  falsefalse  false  false
 false  false  false  false     false  false  false
     ⋮                       ⋱
 false  false  false  false     false  false  false
 false  false  false  false     false  false  false

The value true represents a dark space and false a white square.

There are two optional arguments: the error correction level (explained below) and compact which, when true, removes the white space around the code.

julia> qrcode("Hello world!", High(), compact = true)
25×25 BitArray{2}:
 true   true   true   truetrue   true   true
 true  false  false  false     false  false   true
    ⋮                       ⋱
 true  false  false  false     false  false  false
 true   true   true   true     false  false   true

Export a QR Code as a PNG file

Exporting files is also easy.

julia> exportqrcode("Hello world!")

A file will be saved at ./qrcode.png.

QRCode1

There are three optional parameters.

julia> exportqrcode("Hello world!", "img/hello.png", Medium(), targetsize = 10, compact = true)

This file will be saved as ./img/hello.png (if the img directory already exists), have a size of (approximately) 10 centimeters and be compact. Please note that compact codes may be hard to read depending on their background.

QRCode2

Error Correction Level

QR Codes and be encoded with four error correction levels Low, Medium, Quartile and High. Error correction can restore missing data from the QR code.

  • Low can restore up to 7% of missing codewords.
  • Medium can restore up to 15% of missing codewords.
  • Quartile can restore up to 25% of missing codewords.
  • High can restore up to 30% of missing codewords.

The four levels are encoded as types in QRCode.jl, grouped under the abstract type ErrCorrLevel. Don't forget to use parentheses when you call the values: qrcode("Hello", High()).

Encoding Modes

QR Codes can encode data using several encoding schemes. QRCode.jl supports three of them: Numeric, Alphanumeric and Byte.

Numeric is used for messages composed of digits only, Alphanumeric for messages composed of digits, characters A-Z (capital only) space and % * + - . / : \$, and Bytes for messages composed of ISO 8859-1 or UTF-8 characters. Please not that QR Code reader don't always support arbitrary UTF-8 characters.

Acknowledgments

QRCode.jl was built following this excellent tutorial.

QRCode.jl was created during the Efficient Scientific Computing with Julia workshop, taught by Valentin Churavy at the Okinawa Institute of Science and Technology in July 2019. Slides available here.

Used By Packages

No packages found.