qrtool-encode(1)
NAME
qrtool-encode - encode input data in a QR code
DESCRIPTION
This command encodes input data in a QR code and outputs it as a PNG image, SVG image or string. By default, the result will be output to standard output.
This command will read up to the first 7,090 bytes of the input data. The amount of data that can be represented by a QR code depends on the mode, version and error correction level. The storage capacity is maximized for version 40 and error correction level L (40-L).
Input mode | Max. characters | Possible characters |
---|---|---|
Numeric | 7,089 | 0–9 |
Alphanumeric | 4,296 | 0–9, A–Z (uppercase only), and few symbols (space, |
Byte | 2,953 | Arbitrary binary data |
Kanji | 1,817 | Any double-byte JIS X 0208 character |
By default, this command encodes the input data in a QR code with a black foreground and white background, but this can be changed by specifying --foreground and/or --background. The CSS color string can be specified as a value for these options.
Format | Examples |
---|---|
Named colors |
|
Hexadecimal notations |
|
RGB functions |
|
HSL functions |
|
HWB function |
|
Oklab function |
|
Oklch function |
|
This command can also encode the input data in a Micro QR code. This can embed data in a smaller area than with QR code, but the storage capacity is strongly limited.
qrtool enc and qrtool e are aliases for this command.
POSITIONAL ARGUMENTS
- STRING
Input data. If STRING is not specified, data will be read from standard input. STRING must be a valid UTF-8 string. Use --read-from or read from standard input if taking other than a valid UTF-8 string. This positional argument conflicts with --read-from.
OPTIONS
- -o, --output FILE
Output the result to a file.
- -r, --read-from FILE
Read input data from a file. This option conflicts with STRING.
- -s, --size NUMBER
The module size in pixels. If this option is not specified, the module size is 8 when the output format is PNG or SVG, and 1 otherwise.
- -l, --error-correction-level LEVEL
Error correction level.
- The possible values are:
- l
Level L. 7% of codewords can be restored.
- m
Level M. 15% of codewords can be restored. This is the default value.
- q
Level Q. 25% of codewords can be restored.
- h
Level H. 30% of codewords can be restored.
- --level LEVEL
Alias for -l, --error-correction-level.
- -v, --symbol-version NUMBER
The version of the symbol. If this option is not specified, the minimum version required to store the data will be automatically chosen. For normal QR code, NUMBER should be between 1 and 40. For Micro QR code, NUMBER should be between 1 and 4.
- --symversion NUMBER
Alias for -v, --symbol-version.
- -m, --margin NUMBER
The width of margin. If this option is not specified, the margin will be 4 for normal QR code and 2 for Micro QR code.
- -t, --type FORMAT
The format of the output.
- The possible values are:
- png
Portable Network Graphics. This outputs 32-bit RGBA PNG image. This is the default value.
- svg
Scalable Vector Graphics.
- pic
PIC markup language.
- ansi
To the terminal using 4-bit ANSI escape sequences.
- ansi256
To the terminal using 8-bit ANSI escape sequences.
- ansi-true-color
To the terminal using 24-bit ANSI escape sequences.
- ascii
To the terminal as ASCII string.
- ascii-invert
To the terminal as ASCII string. This value inverts foreground and background colors of ascii and outputs the inverted string. ASCIIi is an alias for this value.
- unicode
To the terminal as UTF-8 string. terminal and UTF8 are aliases for this value.
- unicode-invert
To the terminal as UTF-8 string. This value inverts foreground and background colors of unicode and outputs the inverted string. UTF8i is an alias for this value.
- --optimize-png [LEVEL]
Set the optimization level for a PNG image. Lower levels are faster, higher levels provide better compression. If LEVEL is not specified, it is assumed that the default level 2 is specified.
- The possible values are:
- 0
Level 0. This value is the minimum optimization level.
- 1
Level 1.
- 2
Level 2. This is the default value.
- 3
Level 3.
- 4
Level 4.
- 5
Level 5.
- 6
Level 6. This value is the maximum optimization level.
- max
This value is an alias for the maximum optimization level.
- --zopfli [ITERATION]
Use Zopfli to compress PNG image. Perform compression for the number of iterations specified by ITERATION. If ITERATION is not specified, it is assumed that 15 is specified as the number of iterations. This option requires --optimize-png.
- --mode MODE
The mode of the output. If this option is not specified, use the optimal encoding. This option requires --symbol-version.
- The possible values are:
- numeric
All digits.
- alphanumeric
Alphanumerics and few symbols.
- byte
Arbitrary binary data.
- kanji
Shift JIS text.
- --variant TYPE
The type of QR code. This option requires --symbol-version.
- The possible values are:
- normal
Normal QR code. This is the default value.
- micro
Micro QR code.
- --foreground COLOR
Foreground color. COLOR takes a CSS color string. Colored output is only available when the output format is PNG, SVG or any ANSI escape sequences. Note that lossy conversion may be performed depending on the color space supported by the method to specify a color, the color depth supported by the output format, etc. Default is black.
- --background COLOR
Background color. COLOR takes a CSS color string. Colored output is only available when the output format is PNG, SVG or any ANSI escape sequences. Note that lossy conversion may be performed depending on the color space supported by the method to specify a color, the color depth supported by the output format, etc. Default is white.
- --verbose
Also print the metadata. It is output to stderr.
- -h, --help
Print help message. The short flag (-h) will print a condensed help message while the long flag (--help) will print a detailed help message.
- -V, --version
Print version number. The long flag (--version) will also print the copyright notice, the license notice and where to report bugs.
EXIT STATUS
- 0
Successful program execution.
- 1
An error occurred.
- 2
An error occurred while parsing command-line arguments.
- 65
The input data was incorrect in some way.
- 66
An input file did not exist or was not readable.
- 69
A service is unavailable.
- 71
An operating system error has been detected.
- 74
An error occurred while doing I/O on some file.
- 77
You did not have sufficient permission to perform the operation.
EXAMPLES
- Encode the given string in a QR code:
$ qrtool encode "QR code" > output.png
- Encode the given file and output to the specified image:
$ qrtool encode -o output.png -r go.mod
- Encode to a SVG image:
$ qrtool encode -t svg "QR code" > output.svg
- Encode to a Micro QR code:
$ qrtool encode -v 3 --variant micro "QR code" > output.png
- Encode with the specified colors:
$ qrtool encode -o output.png --foreground brown --background lightslategray "QR code"
COPYRIGHT
Copyright © 2022-2024 Shun Sakai and other contributors
This program is distributed under the terms of either the Apache License 2.0 or the MIT License.
This manual page is distributed under the terms of the Creative Commons Attribution 4.0 International Public License.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.