'\" t .\" Title: qrtool-encode .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2025-11-08 .\" Manual: General Commands Manual .\" Source: qrtool 0.13.2 .\" Language: English .\" .TH "QRTOOL\-ENCODE" "1" "2025-11-08" "qrtool 0.13.2" "General Commands Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" qrtool-encode \- encode input data in a QR code .SH "SYNOPSIS" .sp \fBqrtool encode\fP [\fIOPTION\fP].\|.\|. [\fISTRING\fP] .SH "DESCRIPTION" .sp This command encodes input data in a \c .URL "https://www.qrcode.com" "QR code" "" and outputs it as a PNG image, a SVG image, a string, or other formats. By default, the result will be output to standard output. .sp 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). .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .B Table 1. Maximum character storage capacity (40\-L) .TS allbox tab(:); ltB ltB ltB. T{ .sp Input mode T}:T{ .sp Max. characters T}:T{ .sp Possible characters T} .T& lt lt lt. T{ .sp Numeric T}:T{ .sp 7,089 T}:T{ .sp 0\-9 T} T{ .sp Alphanumeric T}:T{ .sp 4,296 T}:T{ .sp 0\-9, A\-Z (uppercase only), and few symbols (space, \f(CR$\fP, \f(CR%\fP, \f(CR*\fP, \f(CR+\fP, \f(CR\-\fP, \f(CR.\fP, \f(CR/\fP, \f(CR:\fP) T} T{ .sp Byte T}:T{ .sp 2,953 T}:T{ .sp Arbitrary binary data T} T{ .sp Kanji T}:T{ .sp 1,817 T}:T{ .sp Any double\-byte JIS X 0208 character T} .TE .sp .sp 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 \fB\-\-foreground\fP and/or \fB\-\-background\fP. The \c .URL "https://www.w3.org/TR/css\-color\-4/" "CSS color string" "" can be specified as a value for these options. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .B Table 2. List of methods to specify a color .TS allbox tab(:); ltB ltB. T{ .sp Format T}:T{ .sp Examples T} .T& lt lt. T{ .sp Named colors T}:T{ .sp \f(CRbrown\fP, \f(CRlightslategray\fP T} T{ .sp Hexadecimal notations T}:T{ .sp \f(CR#111\fP, \f(CR#eee8\fP, \f(CR#a52a2a\fP, \f(CR#7788997f\fP T} T{ .sp RGB functions T}:T{ .sp \f(CRrgb(165 42 42)\fP, \f(CRrgb(119 136 153 / 49.8%)\fP T} T{ .sp HSL functions T}:T{ .sp \f(CRhsl(248 39% 39.2%)\fP, \f(CRhsl(0 0% 66.3% / 49.8%)\fP T} T{ .sp HWB function T}:T{ .sp \f(CRhwb(50.6 0% 0%)\fP, \f(CRhwb(0 66.3% 33.7% / 49.8%)\fP T} T{ .sp Oklab function T}:T{ .sp \f(CRoklab(50.4% \-0.0906 0.0069)\fP, \f(CRoklab(61.9% \-0.0120 \-0.0302 / 0.5)\fP T} T{ .sp Oklch function T}:T{ .sp \f(CRoklch(59.41% 0.16 301.29)\fP, \f(CRoklch(61.9% 0.032 248.35 / 49.8%)\fP T} .TE .sp .sp In addition to a \c .URL "https://www.qrcode.com/codes/model12.html" "normal QR code" "," this command can also encode the input data in a \c .URL "https://www.qrcode.com/codes/microqr.html" "Micro QR code" "" and a .URL "https://www.qrcode.com/codes/rmqr.html" "rMQR code" "." .SH "POSITIONAL ARGUMENTS" .sp \fISTRING\fP .RS 4 Input data. If \fISTRING\fP is not specified, data will be read from standard input. \fISTRING\fP must be a valid UTF\-8 string. Use \fB\-\-read\-from\fP or read from standard input if taking other than a valid UTF\-8 string. This positional argument conflicts with \fB\-\-read\-from\fP. .RE .SH "OPTIONS" .sp \fB\-o\fP, \fB\-\-output\fP \fIFILE\fP .RS 4 Output the result to a file. .RE .sp \fB\-r\fP, \fB\-\-read\-from\fP \fIFILE\fP .RS 4 Read input data from a file. This option conflicts with \fISTRING\fP. .RE .sp \fB\-s\fP, \fB\-\-size\fP \fINUMBER\fP .RS 4 The module size in pixels. If this option is not specified, the module size is 8 when the output format is PNG, SVG, EPS, or PIC, and 1 otherwise. .RE .sp \fB\-l\fP, \fB\-\-error\-correction\-level\fP \fILEVEL\fP .RS 4 Error correction level. .sp The possible values are: .RS 4 .sp \fBl\fP .RS 4 Level L. 7% of codewords can be restored. .RE .sp \fBm\fP .RS 4 Level M. 15% of codewords can be restored. This is the default value. .RE .sp \fBq\fP .RS 4 Level Q. 25% of codewords can be restored. .RE .sp \fBh\fP .RS 4 Level H. 30% of codewords can be restored. .RE .RE .RE .sp \fB\-\-level\fP \fILEVEL\fP .RS 4 Alias for \fB\-l\fP, \fB\-\-error\-correction\-level\fP. .RE .sp \fB\-v\fP, \fB\-\-symbol\-version\fP \fINUMBER\fP [\fINUMBER\fP] .RS 4 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, \fINUMBER\fP should be between \fB1\fP and \fB40\fP. For Micro QR code, \fINUMBER\fP should be between \fB1\fP and \fB4\fP. For rMQR code, the first \fINUMBER\fP should be \fB7\fP, \fB9\fP, \fB11\fP, \fB13\fP, \fB15\fP, or \fB17\fP. The second \fINUMBER\fP should be \fB27\fP, \fB43\fP, \fB59\fP, \fB77\fP, \fB99\fP, or \fB139\fP. \fB27\fP can only be used with \fB11\fP, or \fB13\fP. If The type of QR code is other than rMQR code, the second \fINUMBER\fP is ignored. .RE .sp \fB\-\-symversion\fP \fINUMBER\fP [\fINUMBER\fP] .RS 4 Alias for \fB\-v\fP, \fB\-\-symbol\-version\fP. .RE .sp \fB\-m\fP, \fB\-\-margin\fP \fINUMBER\fP .RS 4 The width of margin. If this option is not specified, the margin will be 4 for normal QR code and 2 for others. .RE .sp \fB\-t\fP, \fB\-\-type\fP \fIFORMAT\fP .RS 4 The format of the output. .sp The possible values are: .RS 4 .sp \fBpng\fP .RS 4 Portable Network Graphics. This outputs 32\-bit RGBA PNG image. This is the default value. .RE .sp \fBsvg\fP .RS 4 Scalable Vector Graphics. .RE .sp \fBeps\fP .RS 4 Encapsulated PostScript. .RE .sp \fBpic\fP .RS 4 PIC markup language. .RE .sp \fBansi\fP .RS 4 To the terminal using 4\-bit ANSI escape sequences. This value is available if the \f(CRoutput\-as\-ansi\fP feature is enabled at compile time. .RE .sp \fBansi256\fP .RS 4 To the terminal using 8\-bit ANSI escape sequences. This value is available if the \f(CRoutput\-as\-ansi\fP feature is enabled at compile time. .RE .sp \fBansi\-true\-color\fP .RS 4 To the terminal using 24\-bit ANSI escape sequences. This value is available if the \f(CRoutput\-as\-ansi\fP feature is enabled at compile time. .RE .sp \fBascii\fP .RS 4 To the terminal as ASCII string. .RE .sp \fBascii\-invert\fP .RS 4 To the terminal as ASCII string. This value inverts foreground and background colors of \fBascii\fP and outputs the inverted string. \fBASCIIi\fP is an alias for this value. .RE .sp \fBunicode\fP .RS 4 To the terminal as UTF\-8 string. \fBterminal\fP and \fBUTF8\fP are aliases for this value. .RE .sp \fBunicode\-invert\fP .RS 4 To the terminal as UTF\-8 string. This value inverts foreground and background colors of \fBunicode\fP and outputs the inverted string. \fBUTF8i\fP is an alias for this value. .RE .RE .RE .sp \fB\-\-optimize\-png\fP [\fILEVEL\fP] .RS 4 Set the optimization level for a PNG image. Lower levels are faster, higher levels provide better compression. If \fILEVEL\fP is not specified, it is assumed that the default level 2 is specified. This option is available if the \f(CRoptimize\-output\-png\fP feature is enabled at compile time. .sp The possible values are: .RS 4 .sp \fB0\fP .RS 4 Level 0. This value is the minimum optimization level. .RE .sp \fB1\fP .RS 4 Level 1. .RE .sp \fB2\fP .RS 4 Level 2. This is the default value. .RE .sp \fB3\fP .RS 4 Level 3. .RE .sp \fB4\fP .RS 4 Level 4. .RE .sp \fB5\fP .RS 4 Level 5. .RE .sp \fB6\fP .RS 4 Level 6. This value is the maximum optimization level. .RE .sp \fBmax\fP .RS 4 This value is an alias for the maximum optimization level. .RE .RE .RE .sp \fB\-\-zopfli\fP [\fIITERATION\fP] .RS 4 Use Zopfli to compress PNG image. Perform compression for the number of iterations specified by \fIITERATION\fP. If \fIITERATION\fP is not specified, it is assumed that 15 is specified as the number of iterations. This option requires \fB\-\-optimize\-png\fP. This option is available if the \f(CRoptimize\-output\-png\fP feature is enabled at compile time. .RE .sp \fB\-\-mode\fP \fIMODE\fP .RS 4 The mode of the output. If this option is not specified, use the optimal encoding. This option requires \fB\-\-symbol\-version\fP. .sp The possible values are: .RS 4 .sp \fBnumeric\fP .RS 4 All digits. .RE .sp \fBalphanumeric\fP .RS 4 Alphanumerics and few symbols. .RE .sp \fBbyte\fP .RS 4 Arbitrary binary data. .RE .sp \fBkanji\fP .RS 4 Shift JIS text. .RE .RE .RE .sp \fB\-\-variant\fP \fITYPE\fP .RS 4 The type of QR code. .sp The possible values are: .RS 4 .sp \fBnormal\fP .RS 4 Normal QR code. This is the default value. .RE .sp \fBmicro\fP .RS 4 Micro QR code. .RE .sp \fBrmqr\fP .RS 4 rMQR code. .RE .RE .RE .sp \fB\-\-foreground\fP \fICOLOR\fP .RS 4 Foreground color. \fICOLOR\fP 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. .RE .sp \fB\-\-background\fP \fICOLOR\fP .RS 4 Background color. \fICOLOR\fP 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. .RE .sp \fB\-\-verbose\fP .RS 4 Also print the metadata. It is output to stderr. .RE .sp \fB\-h\fP, \fB\-\-help\fP .RS 4 Print help message. The short flag (\fB\-h\fP) will print a condensed help message while the long flag (\fB\-\-help\fP) will print a detailed help message. .RE .sp \fB\-V\fP, \fB\-\-version\fP .RS 4 Print version number. .RE .SH "EXIT STATUS" .sp \fB0\fP .RS 4 Successful program execution. .RE .sp \fB1\fP .RS 4 An error occurred. .RE .sp \fB2\fP .RS 4 An error occurred while parsing command\-line arguments. .RE .sp Exit statuses other than these are defined by .URL "https://man.openbsd.org/sysexits" "\f(CR\fP" "." .SH "NOTES" .sp Source repository: .RS 4 .URL "https://github.com/sorairolake/qrtool" "" "" .RE .SH "EXAMPLES" .sp Encode the given string in a QR code: .RS 4 $ \fBqrtool encode "QR code" > output.png\fP .RE .sp Encode the given file and output to the specified image: .RS 4 $ \fBqrtool encode \-o output.png \-r go.mod\fP .RE .sp Encode in a QR code and output as a SVG image: .RS 4 $ \fBqrtool encode \-t svg "QR code" > output.svg\fP .RE .sp Encode in a Micro QR code: .RS 4 $ \fBqrtool encode \-\-variant micro "QR code" > output.png\fP .RE .sp Encode in a QR code with the specified colors: .RS 4 $ \fBqrtool encode \-o output.png \-\-foreground brown \-\-background lightslategray "QR code"\fP .RE .SH "REPORTING BUGS" .sp Report bugs to: .RS 4 .URL "https://github.com/sorairolake/qrtool/issues" "" "" .RE .SH "COPYRIGHT" .sp Copyright \(co 2022 Shun Sakai and contributors .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ . sp -1 . IP " 1." 4.2 .\} This program is distributed under the terms of either the Apache License 2.0 or the MIT License. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ . sp -1 . IP " 2." 4.2 .\} This manual page is distributed under the terms of the Creative Commons Attribution 4.0 International Public License. .RE .sp This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH "SEE ALSO" .sp \fBoxipng\fP(1), \fBqrencode\fP(1), \fBqrtool\fP(1), \fBqrtool\-completion\fP(1), \fBqrtool\-decode\fP(1)