QR Code creation from the command line

The command line script segno can be used to print QR Codes to the terminal or to save them as file (SVG, PNG, EPS, …).

By default, the script does not create Micro QR Codes, use --micro to allow the creation of Micro QR Codes or specify the version (like --version=M3) to create a Micro QR Code.

See the CLI man page for a detailed reference of all command line options.

Usage

Output the QR Code to the terminal:

$ segno "Little wing"
QR Code for "Little wing".

Same content, but as Micro QR Code (M4):

$ segno --micro "Little wing"
Micro QR Code for "Little wing".

Version

If the --version parameter is not provided, Segno chooses the minimal version for the QR Code automatically. The version may be specified as integer or as Micro QR Code identifier.

The content ‘Layla’ would fit into a version 1 QR Code, but the following command enforces version 5:

$ segno --version=5 Layla
$ segno -v=5 Layla
QR Code version 5 for "Layla".

Micro QR Code:

$ segno -v m4 Layla
$ segno --version M4 Layla
Micro QR Code version M4 for "Layla".

Error correction level

The default error correction level is “L” (or any better if --no-error-boost was not set, c.f. Boost Error Correction Level), use the --error parameter to change it:

$ segno --error=q "Ain't no grave"
$ segno -e=h "Heart of Gold"

“Heart of Gold” using error level “L”:

QR Code "Heart of Gold" using error level L

“Heart of Gold” using error level “H”:

QR Code "Heart of Gold" using error level H

QR Code serialization

Printing the QR Codes to the terminal is nice but the --output parameter serializes the QR Code in one of the supported file formats:

$ segno --output=white-room.png "White Room"
QR Code "White Room".
$ segno -o=satellite.svg "Satellite Of Love"
QR Code "Satellite Of Love".
$ segno --output=mrs.eps "Mrs. Robinson"
$ segno --output=dedodo.pdf "De Do Do Do, De Da Da Da"
$ segno --output=tin-pan-alley.svgz "Tin Pan Alley"
$ segno --output=thrill-gone.txt "The Thrill Is Gone"
000000000000000000000000000000000
000000000000000000000000000000000
000000000000000000000000000000000
000000000000000000000000000000000
000011111110101110110011111110000
000010000010111011110010000010000
000010111010100010010010111010000
000010111010111011000010111010000
000010111010100010110010111010000
000010000010001111011010000010000
000011111110101010101011111110000
000000000000110101001000000000000
000001101011000000111010111110000
000010010101000100001110000110000
000000001111000101000100111110000
000000000100010000001100110100000
000011101011001000001010000000000
000001000000100010011110010110000
000010001111000101001011101110000
000001110000100000010101100100000
000010001011110111101111111110000
000000000000110001011000100000000
000011111110110011011010101110000
000010000010001011111000100110000
000010111010101100101111100010000
000010111010010110101001111000000
000010111010101101101011101010000
000010000010111011001111100100000
000011111110010011011110110110000
000000000000000000000000000000000
000000000000000000000000000000000
000000000000000000000000000000000
000000000000000000000000000000000

Scaling QR Codes

If the resulting QR Code is too small, --scale can be used to create a more appropriate output:

$ segno --scale=10 --output=money-talks.png "Money Talks"
QR Code "Money Talks".
$ segno -s 10 --output=private-investigations.svg Private Investigations
QR Code "Private Investigations".

If the serializer does not support a scaling factor (i.e. text output), this parameter is ignored.

Changing the size of the quiet zone

The generated QR Codes will have a recommended quiet zone / border around the symbol. To change the size of the border, --border can be utilized:

$ segno --border=0 --output=black-magic-woman.svg "Black Magic Woman"
QR Code "Black Magic Woman" using quiet zone of zero.
$ segno --border=10 --output=diamond.png "Shine On You Crazy Diamond"
QR Code "Shine On You Crazy Diamond" using quiet zone of ten.
$ segno -b=30 --output=boom-boom.svg Boom Boom
QR Code "Boom Boom" using quiet zone of 30.

Colors

Usually, all QR Codes are serialized in black and white. Use --color to change the color of the dark modules and --background to change the color of the light modules.

Change the foreground color to darkblue:

$ segno --color=darkblue --output=excited.png "So Excited"
QR Code "So Excited" with foreground color "darkblue"

Change the background color to transparent:

$ segno --background=transparent --output=hotel.png "Hotel California"
QR Code "Hotel California" with background color "transparent"

Change the foreground color to darkblue and background to yellow:

$ segno --color=darkblue --background=yellow --output=dontgiveup.svg "Don't Give Up"
QR Code "Don't Give Up" with foreground color "transparent"

If the serializer does not support --color or --background, these arguments are ignored.

Structured Append

The Structured Append mode can be used to split a message across multiple (max. 16) QR Codes.

To create a sequence of QR Codes, the --seq argument must be provided. Additonally, either the QR Code --version or the desired number of symbols (--symbol-count) must be provided:

$ segno --seq -v 1 "Well you should see Polythene Pam"
$ segno --seq --symbol-count=2 "We all live in a yellow submarine"
$ segno --seq -sc 2 "Half of what I say is meaningless"