Creating QR Codes with `qrencode`

By David Chen @TheEgghead27

I was working on some posters for Stuy Linux, and needed to generate a few QR codes. Needless to say, I turned to FOSS command-line tools!

Installing qrencode

Technically, I lied to all of you in the title!! The project is actually libqrencode.

The library has minimal dependencies, with only libpng for writing PNG, and SDL for test suites, and both are optional.

Thus, on most Unix-based systems, like GNU/Linux, you should easily be able to compile libqrencode yourself from the project homepage, you mainly need autoconf and make tooling, along with basic compiling tools.

The homepage also mentions a Windows port, and a MacOS homebrew package.

Using qrencode

Using qrencode is super simple, barely an inconvenience!

qrencode -o [FILE] [text]

For example, to generate a QR code reading https://stuylinux.org, -outputted to qr.png, I would run

qrencode -o qr.png https://stuylinux.org

If you type qrencode with no arguments, it will print a helpful summary of the optioins available. Play around with them!

Reading the outputted QR code

Most smartphones nowadays come with QR code scanners embedded in their Camera apps (usually, it is suboptimal to use a third-party app, as they usually are proprietary and contain privacy-invading advertisements).

A helpful cross-platform tool to scan QR codes with is zbar, which is usually installed with the package named zbar.

To scan the QR code from the terminal, run

zbarimg [image]

or

zbarimg --quiet --raw [image]

to obtain the unedited output, with no extraneous warnings.

That's all for this blog entry, see you around!

go home