Usage
Basic usage
qrtool encode "QR code" > output.png
qrtool decode output.png
QR code
SVG generation
Use -t
option to change the format of the generated image. The format is
png
(default), svg
or terminal
(to the terminal as UTF-8 string).
qrtool encode -o output.svg -t svg "QR code"
Micro QR code generation
Use --variant
option to change the variant of the generated QR code. The
variant is normal
(default) or micro
(Micro QR code).
qrtool encode -v 3 --variant micro "QR code" > output.png
Colored output
Use --foreground
and --background
options to change the foreground and
background colors of the generated image. These options takes a
CSS color string such as brown
, #a52a2a
or
rgb(165 42 42)
. The default foreground color is black and the background
color is white of CSS’s named colors.
qrtool encode --foreground brown --background lightslategray "QR code" > output.png
Supported input image formats
qrtool decode
supports decoding a QR code from the following image formatsTo support decoding from SVG image, the decode-from-svg
feature must be
enabled at compile time. Note that the SVG image is rasterized before scanning.
Image formats other than PNG can be disabled by disabling the default
feature, and can be enabled individually.
Use -t
option to specify the image format. If this option is not specified,
the image format is determined based on the extension or the magic number.
qrtool decode input.webp
# or
qrtool decode -t webp input.webp
QR code
Generate shell completion
--generate-completion
option generates shell completions to stdout.
bash
elvish
fish
nushell
powershell
zsh
qrtool --generate-completion bash > qrtool.bash
Integration with other programs
Both qrtool encode
and qrtool decode
can read from stdin and output to
stdout.
Optimize the output image
The image output by qrtool encode
is not optimized. For example, a PNG image
is always output as the 32-bit RGBA format. If you want to reduce the image
size or optimize the image, use an optimizer such as
oxipng
or svgcleaner
.
qrtool encode "QR code" | oxipng - > output.png
qrtool encode -t svg "QR code" | svgcleaner -c - > output.svg
Reading and writing unsupported image formats
If you want to save the encoded image in an image format other than PNG or SVG, or decode an image in an unsupported image format, convert it using a converter such as ImageMagick.
Cargo.toml
from stdin and save the encoded result as a JPEG XL imagecat Cargo.toml | qrtool encode | magick png:- output.jxl
bat
magick output.jxl png:- | qrtool decode | bat -l toml