LinuxCommandLibrary

qr

Generate QR codes from text

TLDR

Generate a QR code

$ qr "[data]"
copy

Specify the error correction level (defaults to M)
$ qr --error-correction [L|M|Q|H] "[data]"
copy

Generate a QR code from the output of another command
$ [command] | qr
copy

Save the QR code as a PNG image
$ qr "[data]" > [path/to/file.png]
copy

SYNOPSIS

qrencode [OPTIONS] [STRING...]

PARAMETERS

-o FILE
    Output to FILE instead of standard output (stdout).

-s SIZE
    Specify module size in pixels (default: 3). A larger size results in a physically larger QR code image.

-l LEVEL
    Set error correction level (L, M, Q, H). Higher levels provide more resilience but result in larger QR codes.

-t TYPE
    Specify output image type (PNG, SVG, ASCII, ANSI, UTF8, ANSI256). ASCII, ANSI, UTF8, and ANSI256 display directly in the terminal.

-r FILE
    Read input data from FILE instead of command-line arguments or standard input.

-d DPI
    Set DPI (dots per inch) for PNG output (default: 72). Affects print resolution without changing module size.

-m MARGIN
    Set margin width in modules (default: 4). This is the quiet zone around the QR code.

-v
    Show version information of the qrencode utility.

-h
    Show help message and exit, listing available options.

DESCRIPTION

qrencode is a powerful command-line utility designed to encode data into a QR (Quick Response) Code symbol. It can take input from command-line arguments, standard input, or a file, and generate QR codes in various formats, including PNG image files, SVG vector graphics, or even ASCII art directly to the terminal. The command allows users to control aspects like the size of the QR code, the error correction level (which determines resilience to damage), and the output file name, making it highly versatile for integration into scripts or for quick on-the-fly QR code generation. It's built upon the libqrencode library.

CAVEATS

The qr command typically refers to qrencode or a similar utility, which might not be installed by default on all Linux distributions. It usually requires the libqrencode development libraries and libpng for image output. Ensure it's installed via your distribution's package manager (e.g., sudo apt install qrencode on Debian/Ubuntu, sudo yum install qrencode on Fedora/RHEL).

ERROR CORRECTION LEVELS

qrencode supports four levels of error correction, which determine how much damage a QR code can sustain and still be readable:
L: Low, 7% of codewords can be restored.
M: Medium, 15% of codewords can be restored (default).
Q: Quartile, 25% of codewords can be restored.
H: High, 30% of codewords can be restored.
Higher error correction levels result in larger QR codes for the same data content.

OUTPUT TYPES

Beyond common image formats like PNG and SVG, qrencode can output QR codes directly to the terminal using ASCII art, ANSI escape codes, or UTF-8 characters. This is particularly useful for quick display or for embedding QR codes in text-based environments without creating image files.

HISTORY

The qrencode utility is part of the libqrencode project, which was started around 2008 by Kentaro Fukuchi. It provides a highly efficient and compliant C library for encoding data into QR Code symbols. The command-line tool qrencode serves as a practical frontend to this library, quickly becoming a de facto standard for command-line QR code generation in the Linux ecosystem due to its simplicity, speed, and robust feature set.

SEE ALSO

zbarimg(1), convert(1), display(1)

Copied to clipboard