/QR-util

A command-line utility for generating QR codes

Primary LanguageCMIT LicenseMIT

QR-util

A command-line utility for generating QR codes which store text!

How to Use

Help

To view the help text for qrutil use:

qrutil --help

or

qrutil -h

Store User Input

Here is one simple way of generating a qr code from user input. Run the following:

qrutil qrcode.bmp

which will generate a qr code stored to the file qrcode.bmp. Then enter the data you want to generate. To generate the code, press ENTER then ctrl+D (or ctrl+Z on Windows).

Piping Data

Alternatively, you can pipe your text into qrutil. For instance, if you wanted to generate a qr code which stored the text hello world in the qr code file named qrcode.bmp, you could run the following:

echo "hello world" | qrutil qrcode.bmp

Or, if you wanted to generate a qr code which stored 20 random bytes, you could run this:

head -c 20 /dev/urandom | qrutil qrcode.bmp

Upscaling

If you view the output files generated by such commands with an image viewer, you may see that the images are blurred. This is because each square of the qr code by default occupies one pixel. This can be changed, however, using the upscaling argument:

echo "hello world" | qrutil -u 10 qrcode.bmp

This will generate a qr code in which instead each qr code sqare occupies a 10 pixel by 10 pixel area.

Error Correction

By default, qrutil tries to generate the smallest qr code it can. However, qr codes support 4 modes of error correction which can make qr codes more robust to damage. In qrutil, an error correction level of 4 corrects for the most errors. On the other hand, a qr code with error correction level of 1 would not withstand as much damage. To specify the error correction level, use the -c option:

echo "hello world" | qrutil -c 4 qrcode.bmp

This would ensure that the qr code which is generated has the highest level of error correction.

Version number

There are 40 versions of qr codes (1-40), with increasing versions being bigger and able to store more data. You can force qrutil to use a specific version using the -v option:

echo "hello world" | qrutil -v 40 qrcode.bmp

This would make a very big qr code which just stores the text hello world. Note that bigger qr codes are significantly harder to scan using qr code scanners.

Inverting

Qr codes also support an "inverted" mode in which the background is black and the color of each module is reversed. To create an inverted qr code, use '-i':

echo "hello world" | qrutil -u 10 -i qrcode.bmp

Mask

By default, qrutil tries to choose the best of the 8 possible masks that can be used to generate qr codes. You can instead specify which mask to use using -m [num] where [num] is an integer between 1 and 8:

echo "hello world" | qrutil -u 10 -m 7 qrcode.bmp

Verbose mode

qrutil can print out information about the qr code it generates. Use the --verbose option:

echo "hello world" | qrutil --verbose qrcode.bmp

which would output:

Version: 1
Error Correction: 3
Mask: 5
Upscaling: 1

If you generate a qr code which can't be read, or you find any other bugs regarding qrutil then feel free to raise an issue!